解决Python3 urllib3 urllib3.exceptions.maxretryerror httpsconnectionpool(host=‘xxxxx‘, port=443)
报错原因
在使用代理进行请求时,代理只通过HTTP
请求,此时请求进行HTTPS
验证时验证失败。
两种解决方案
- 在
1.25
版本之前,请求时不会进行HTTPS验证。故可降低urllib3版本。
1 1.25 (2019-04-22)
2 Require and validate certificates by default when using HTTPS (Pull #1507)
1pip install -U "urllib3<1.25"
-
修改本地代理,将HTTPS覆盖为HTTP请求
Windows 10下打开设置 -> 网络和Internet -> 代理,找到代理的IP和端口
1proxies = { 2 'http': 'http://127.0.0.1:1080', 3 'https': 'http://127.0.0.1:1080' 4} 5res = requests.post(url, data=data, timeout=15, proxies=proxies)