派请求,'No connection adapters were found'


File "/usr/lib/python3/dist-packages/requests/api.py", line 67, in get
return request('get', url, params=params, **kwargs)
File "/usr/lib/python3/dist-packages/requests/api.py", line 53, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 468, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 570, in send
adapter = self.get_adapter(url=request.url)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 644, in get_adapter
raise InvalidSchema("No connection adapters were found for '%s'" % url)
requests.exceptions.InvalidSchema: No connection adapters were found for '"https://framework.zend.com/manual/1.12/en/manual.html"'

该网址具有https,并且我已经从我的终端向该网址运行了请求,没有问题,所以我不知道为什么它找不到适配器。我已经查看了源代码,它肯定适用于默认连接适配器下的https

self.adapters = OrderedDict()
self.mount('https://', HTTPAdapter())
self.mount('http://', HTTPAdapter())

感谢您的任何帮助

法典:

def fetchUrl(self, url):
response = requests.get(url, params=self.PAYLOAD)

和有效载荷

PAYLOAD = {
'timeout': 60,
'headers': {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1'
}
}

url参数中有多余的引号。

仔细查看错误消息中的 URL 字符串,它说(注意引号(

requests.exceptions.InvalidSchema: No connection adapters were found for '"https://framework.zend.com/manual/1.12/en/manual.html"'

相反,它应该说

requests.exceptions.InvalidSchema: No connection adapters were found for 'https://framework.zend.com/manual/1.12/en/manual.html'

相关内容

最新更新