requests.exceptions.SSLError: HTTPSConnectionPool Max retries exceeded with url 报错解决方法

2022-06-26 08:59:31 浏览数 (1)

代码语言:javascript复制
import requests
import json

headers = {"Content-Type": "application/json"}
url = 'https://xxx'
d = {"var": [1, 2, 3]}
r = requests.post(url, headers=headers, json=d)  # 发get请求
print(r.status_code, r.json())

发现报错:

代码语言:javascript复制
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] 
certificate verify failed: certificate has expired (_ssl.c:1131)


requests.exceptions.SSLError: HTTPSConnectionPool(host='xxx', port=xxx): 
Max retries exceeded with url: /xxx 
(Caused by SSLError(SSLCertVerificationError
(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: 
certificate has expired (_ssl.c:1131)')))

修改方法:

urlhttps 改为 http 不报错了

0 人点赞