python爬虫遇到 raise SSLError(e, request=request) : HTTPSConnectionPool

时间:2025-02-11 14:00:38

python爬虫遇到ssl证书报错
(host=’’, port=443): Max retries exceeded with url:
Caused by SSLError(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1123)’)))

只需两步

import requests
# 1.增加下面两行
import urllib3
urllib3.disable_warnings()

# 2.在requests中增加 verify=False
response = requests.get(url=url, headers=headers, verify=False)

参考资料
/en/latest/#tls-warnings