requests.exceptions.SSLError报错
requests.exceptions.SSLError: HTTPSConnectionPool(host=‘mail.163.com’, port=443): Max retries exceeded with url: /js6/main.jsp?sid=OAdzxPQHWOawsVyPhxHHKIJQCVTeqPfu&df=mail163_letter (Caused by SSLError(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1108)’)))
错误提示如上。
有很多人说关闭证书验证(verify=False))可以解决这个问题或者说是在进行GET时,指定SSL证书.
response = requests.get(‘http://www.baidu.com/’, headers = header, verify=False)
但我用以上两种方法都没有完美解决此问题,而且有些还有后续错误比如InsecureRequestWarning
还看到如下答案:
正确的做法参考文档资料
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
https://urllib3.readthedocs.io/en/latest/user-guide.html#ssl
参考博客:http://blog.csdn.net/zahuopuboss/article/details/52964809
只要安装一下几个requests依赖包就可以解决此问题
pip install cryptography
pip install pyOpenSSL
pip install certifi
这个方法我也是了,发现cryptography和pyOpenSSL两个模块安装不了
最后我才发现我的问题,居然是因为Charles。。。
只要把它关了就可以了。
如果你用的是fiddler之类的代理,也同样有效
本文详细介绍了在使用Python的requests库时遇到的SSLError问题,并提供了多种解决方案,包括安装依赖包和调整Charles代理设置。最终确定关闭Charles代理为最有效的方法。

4129

被折叠的 条评论
为什么被折叠?



