安装了 python request, 但是运行时,老是提示Failed to establish a new connection
我已经安装了python 2.7,并安装 requests-2.18.1, 执行import requests,没有提示任何错误,然后我尝试用get 方法来获取一个request, 但一直提示 Failed to establish a new connection,请看下图
C:\Users\fangbin\Desktop、1.png
图没出来 截图没有上传上来
对的图没上来 你的请求头有问题 C:\Users\fangbin\Desktop\1.png 抱歉,我不知道为什么上传不了图片,我把内容贴过来
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40) on win32
Type "copyright", "credits" or "license()" for more information.
>>> import requests
>>> R = requests.get('http://www.zhidao.com')
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
R = requests.get('http://www.zhidao.com')
File "C:\Python27\lib\site-packages\requests-2.18.1-py2.7.egg\requests\api.py", line 72, in get
return request('get', url, params=params, **kwargs)
File "C:\Python27\lib\site-packages\requests-2.18.1-py2.7.egg\requests\api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Python27\lib\site-packages\requests-2.18.1-py2.7.egg\requests\sessions.py", line 502, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python27\lib\site-packages\requests-2.18.1-py2.7.egg\requests\sessions.py", line 612, in send
r = adapter.send(request, **kwargs)
File "C:\Python27\lib\site-packages\requests-2.18.1-py2.7.egg\requests\adapters.py", line 504, in send
raise ConnectionError(e, request=request)
ConnectionError: HTTPConnectionPool(host='www.zhidao.com', port=80): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x0000000003E599E8>: Failed to establish a new connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond',))
>>>
页:
[1]