我在执行代码response = session.post(url, headers=header)
时,
出现requests.exceptions.ProxyError: HTTPConnectionPool(host='127.0.0.1', port=7890): Max retries exceeded with url: http://xxxxx (Caused by ProxyError('Cannot connect to proxy.', RemoteDisconnected('Remote end closed connection without response')))
异常。
我的电脑中装了代理软件,关闭时代码执行正常,开启之后出现异常。
如果你的情况与我类似,可以添加以下代码,在开启代理工具之后仍然能够正常执行:
# 指定某个域名不用代理去处理
os.environ['NO_PROXY'] = '你访问的域名(例:www.baidu.com)'