问题
python requests 请求r = requests.get(‘https://httpbin.testing-studio.com/get’,params = payload) 报错
报错信息
E:\pycharmproject\venv\Scripts\python.exe E:\pycharmproject\main.py
Traceback (most recent call last):
File “E:\pycharmproject\venv\lib\site-packages\urllib3\connectionpool.py”, line 467, in _make_request
self._validate_conn(conn)
File “E:\pycharmproject\venv\lib\site-packages\urllib3\connectionpool.py”, line 1092, in _validate_conn
conn.connect()
File “E:\pycharmproject\venv\lib\site-packages\urllib3\connection.py”, line 642, in connect
sock_and_verified = _ssl_wrap_socket_and_match_hostname(
File “E:\pycharmproject\venv\lib\site-packages\urllib3\connection.py”, line 783, in ssl_wrap_socket_and_match_hostname
ssl_sock = ssl_wrap_socket(
File "E:\pycharmproject\venv\lib\site-packages\urllib3\util\ssl.py", line 469, in ssl_wrap_socket
ssl_sock = ssl_wrap_socket_impl(sock, context, tls_in_tls, server_hostname)
File "E:\pycharmproject\venv\lib\site-packages\urllib3\util\ssl.py", line 513, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File “C:\Users\111\AppData\Local\Programs\Python\Python39\lib\ssl.py”, line 501, in wrap_socket
return self.sslsocket_class._create(
File “C:\Users\111\AppData\Local\Programs\Python\Python39\lib\ssl.py”, line 1041, in _create
self.do_handshake()
File “C:\Users\111\AppData\Local\Programs\Python\Python39\lib\ssl.py”, line 1310, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “E:\pycharmproject\venv\lib\site-packages\urllib3\connectionpool.py”, line 790, in urlopen
response = self._make_request(
File “E:\pycharmproject\venv\lib\site-packages\urllib3\connectionpool.py”, line 491, in _make_request
raise new_e
urllib3.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File “E:\pycharmproject\venv\lib\site-packages\requests\adapters.py”, line 486, in send
resp = conn.urlopen(
File “E:\pycharmproject\venv\lib\site-packages\urllib3\connectionpool.py”, line 844, in urlopen
retries = retries.increment(
File “E:\pycharmproject\venv\lib\site-packages\urllib3\util\retry.py”, line 515, in increment
raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type]
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host=‘httpbin.testing-studio.com’, port=443): Max retries exceeded with url: /get?level=1&name=zhangsan (Caused by SSLError(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)’)))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “E:\pycharmproject\main.py”, line 15, in
m.get_query();
File “E:\pycharmproject\main.py”, line 9, in get_query
r = requests.get(‘https://httpbin.testing-studio.com/get’,params = payload)
File “E:\pycharmproject\venv\lib\site-packages\requests\api.py”, line 73, in get
return request(“get”, url, params=params, **kwargs)
File “E:\pycharmproject\venv\lib\site-packages\requests\api.py”, line 59, in request
return session.request(method=method, url=url, **kwargs)
File “E:\pycharmproject\venv\lib\site-packages\requests\sessions.py”, line 589, in request
resp = self.send(prep, **send_kwargs)
File “E:\pycharmproject\venv\lib\site-packages\requests\sessions.py”, line 703, in send
r = adapter.send(request, **kwargs)
File “E:\pycharmproject\venv\lib\site-packages\requests\adapters.py”, line 517, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host=‘httpbin.testing-studio.com’, port=443): Max retries exceeded with url: /get?level=1&name=zhangsan (Caused by SSLError(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)’)))
进程已结束,退出代码1