requests.exceptions.SSLError: HTTPSConnectionPool(host='www.baidu.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)'),))
錯誤提示就是上面這樣的。首先我找了很多的資料,有很多人說關(guān)閉證書驗證(verify=False))可以解決這個問題或者說是在進(jìn)行GET時,指定SSL證書.
response = requests.get('http://www.baidu.com/', headers = header, verify=False)
但我用以上兩種方法都沒有完美解決此問題,而且有些還有后續(xù)錯誤比如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文章來源:http://www.zghlxwxcb.cn/news/detail-736219.html
保存記錄一下錯誤文章來源地址http://www.zghlxwxcb.cn/news/detail-736219.html
到了這里,關(guān)于python使用requests時報錯requests.exceptions.SSLError:HTTPSConnectionPool的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!