Python requests.exceptions.ProxyError的解决办法
首页 / 频道 / 显示主题:Python requests.exceptions.ProxyError的解决办法

Python requests.exceptions.ProxyError的解决办法


时间:2020年05月26日 15:20:57点击:2276类别:解决方案

今天在使用Python requests.get的时候老是报错,我也没有找出具体原因,在网上看到一个原因是:

http的连接数超过最大限制,默认的情况下连接是Keep-alive的,所以这就导致了服务器保持了太多连接而不能再新建连接。

我以为是我之前采集某API的时候使用requests.get太多的原因,也有人说可能安装shadowsock后不小心设置了全局代理的原因,反正我使用requests.get的时候老是出现如下的错误:

requests.exceptions.ProxyError: HTTPSConnectionPool(host='www.baidu.com', port=4
43): Max retries exceeded with url: / (Caused by ProxyError('Cannot connect to p
roxy.', NewConnectionError(': Failed to establish a new connection: [
WinError 10061] No connection could be made because the target machine actively
refused it',)))

后来在网上找到的解决方法是在程序中加入如下代码就可以使用了:

1 import os
2 os.environ['NO_PROXY'] = 'stackoverflow.com'

本文暂无标签

楼主低端人口9527

喜欢:(2276)  回复:(0)

0

以下为回复内容


读后有收获可以添加作者微信共同交流
打赏作者


也回复一个  举报