为了账号安全,请及时绑定邮箱和手机立即绑定

Python HTTPS 请求 SSLError CERTIFICATE_VERIFY_FAILED

Python HTTPS 请求 SSLError CERTIFICATE_VERIFY_FAILED

湖上湖 2021-07-09 14:11:32
PYTHONimport requestsurl = "https://REDACTED/pb/s/api/auth/login"r = requests.post(    url,    data = {        'username': 'username',        'password': 'password'    })尼姆import httpclient, jsonlet client = newHttpClient()client.headers = newHttpHeaders({ "Content-Type": "application/json" })let body = %*{    "username": "username",    "password": "password"}let resp = client.request("https://REDACTED.com/pb/s/api/auth/login", httpMethod = httpPOST, body = $body)echo resp.body我正在调用 API 来获取一些数据。运行 python 代码,我得到了下面的回溯。但是,nim 代码运行良好,因此python 代码或设置肯定有问题。我正在运行 Python 版本 2.7.15。请求库版本 2.19.1Traceback (most recent call last):  File "C:/Python27/testht.py", line 21, in <module>    "Referer": "https://REDACTED.com/pb/a/"  File "C:\Python27\lib\site-packages\requests\api.py", line 112, in post    return request('post', url, data=data, json=json, **kwargs)  File "C:\Python27\lib\site-packages\requests\api.py", line 58, in request    return session.request(method=method, url=url, **kwargs)  File "C:\Python27\lib\site-packages\requests\sessions.py", line 512, in request    resp = self.send(prep, **send_kwargs)  File "C:\Python27\lib\site-packages\requests\sessions.py", line 622, in send    r = adapter.send(request, **kwargs)  File "C:\Python27\lib\site-packages\requests\adapters.py", line 511, in send    raise SSLError(e, request=request)SSLError: HTTPSConnectionPool(host='REDACTED.com', port=443): Max retries exceeded with url: /pb/s/api/auth/login (Caused by SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:726)'),))
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 190 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信