Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 未找到Python3请求的连接适配器_Python 3.x_Python Requests - Fatal编程技术网

Python 3.x 未找到Python3请求的连接适配器

Python 3.x 未找到Python3请求的连接适配器,python-3.x,python-requests,Python 3.x,Python Requests,我正在使用python3中的Beauty soup with requests包进行web抓取。这是我的密码 import csv from datetime import datetime import requests import csv from datetime import datetime from bs4 import BeautifulSoup quote_page = ['http://10.69.161.179:8080']; data = [] page

我正在使用python3中的Beauty soup with requests包进行web抓取。这是我的密码

import csv  
from datetime import datetime
import requests
import csv  
from datetime import datetime 
from bs4 import BeautifulSoup


quote_page = ['http://10.69.161.179:8080'];

data = []

page = requests.get(quote_page)

soup = BeautifulSoup(page.content,'html.parser')

name_box = soup.find('div', attrs={'class':'caption span10'})

name= name_box.text.strip() #strip() is used to remove starting and ending

print(name);

data.append(name)

    

with open('sample.csv', 'a') as csv_file:  
    writer = csv.writer(csv_file)
    writer.writerow([name])

print ("Success");
当我执行上述代码时,我得到以下错误

Traceback (most recent call last):
  File "first_try.py", line 21, in <module>
    page = requests.get(quote_page);
  File "C:\Python\lib\site-packages\requests-2.13.0-py3.6.egg\requests\api.py", line 70, in get
    return request('get', url, params=params, **kwargs)
  File "C:\Python\lib\site-packages\requests-2.13.0-py3.6.egg\requests\api.py", line 56, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Python\lib\site-packages\requests-2.13.0-py3.6.egg\requests\sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Python\lib\site-packages\requests-2.13.0-py3.6.egg\requests\sessions.py", line 603, in send
    adapter = self.get_adapter(url=request.url)
  File "C:\Python\lib\site-packages\requests-2.13.0-py3.6.egg\requests\sessions.py", line 685, in get_adapter
    raise InvalidSchema("No connection adapters were found for '%s'" % url)
requests.exceptions.InvalidSchema: No connection adapters were found for '['http://10.69.161.179:8080/#/main/dashboard/metrics']'
回溯(最近一次呼叫最后一次):
文件“first_try.py”,第21行,在
page=requests.get(引用页面);
文件“C:\Python\lib\site packages\requests-2.13.0-py3.6.egg\requests\api.py”,第70行,在get中
返回请求('get',url,params=params,**kwargs)
文件“C:\Python\lib\site packages\requests-2.13.0-py3.6.egg\requests\api.py”,请求中的第56行
return session.request(method=method,url=url,**kwargs)
文件“C:\Python\lib\site packages\requests-2.13.0-py3.6.egg\requests\sessions.py”,请求中第488行
resp=自我发送(准备,**发送)
文件“C:\Python\lib\site packages\requests-2.13.0-py3.6.egg\requests\sessions.py”,第603行,在send中
adapter=self.get\u适配器(url=request.url)
文件“C:\Python\lib\site packages\requests-2.13.0-py3.6.egg\requests\sessions.py”,第685行,在get_适配器中
raise InvalidSchema(“未找到“%s”的连接适配器%url)
requests.exceptions.InvalidSchema:找不到“[”的连接适配器http://10.69.161.179:8080/#/main/dashboard/metrics']'
有人能帮我吗(

因为requests.get()只接受字符串格式的url架构。您需要在列表[]中解包字符串

quote_page = ['http://10.69.161.179:8080']
for url in quote_page:
  page = requests.get(url)
  .....
顺便说一句,虽然分号在下面的语句中是无害的,但除非

因为requests.get()只接受字符串格式的url架构。您需要在列表[]中解包字符串

quote_page = ['http://10.69.161.179:8080']
for url in quote_page:
  page = requests.get(url)
  .....
顺便说一句,虽然分号在下面的语句中是无害的,但除非