编写爬虫时使用代理出现 ConnectionResetError: [Errno 54]错误怎么解决?
0
import requests headers = { 'Accept':'application/json, text/plain, */*', 'Accept-Language':'zh-CN,zh;q=0.8', 'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36' } proxies = {'http': 'http://117.63.8.194:9287', 'https': 'http://117.63.8.194:9287'} url = 'https://www.zhihu.com/' html = requests.get(url, headers=headers,proxies=proxies) print(html)代理可以用的,不用代理就没事,用代理访问其他网站一样报这个错误
ConnectionResetError: [Errno 54] Connection reset by peer
During handling of the above exception, another exception occurred:
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='http://www.zhihu.com', port=443): Max retries exceeded with url: / (Caused by ProxyError('Cannot connect to proxy.', ConnectionResetError(54, 'Connection reset by peer')))
During handling of the above exception, another exception occurred:
requests.exceptions.ProxyError: HTTPSConnectionPool(host='http://www.zhihu.com', port=443): Max retries exceeded with url: / (Caused by ProxyError('Cannot connect to proxy.', ConnectionResetError(54, 'Connection reset by peer')))
没有找到相关结果
重要提示:提问者不能发表回复,可以通过评论与回答者沟通,沟通后可以通过编辑功能完善问题描述,以便后续其他人能够更容易理解问题.
2 个回复
一只写程序的猿 - 一个圣骑士成熟的标志是不再向盲人解释阳光。公众号:Python攻城狮 2017-10-26 回答
赞同来自:
ID王大伟 - 人生苦短,我选Python。 2017-09-26 回答
赞同来自: