Python version: python 3.8
Target web address: https://data.stats.gov.cn/easyquery.htm? Cn=A01
Code:
The import requests
Headers={' the user-agent ':' Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.163 Safari/535.1 '}
The response=requests. Get (' https://data.stats.gov.cn/easyquery.htm? Cn=A01 'headers=headers)
The response. The encoding="utf-8"
Print (response. Status_code)
Print (response. The text)
Error message
Traceback (the most recent call last) :
The File "D: \ Python \ Python38-32 \ lib \ site - packages \ urllib3 \ connectionpool py", line 667, in urlopen
Self. _prepare_proxy (conn)
The File "D: \ Python \ Python38-32 \ lib \ site - packages \ urllib3 \ connectionpool py", line 932, in _prepare_proxy
Conn. The connect ()
The File "D: \ Python \ Python38-32 \ lib \ site - packages \ urllib3 \ connection py", line 362, in the connect
The self. The sock=ssl_wrap_socket (
The File "D: \ Python \ Python38-32 \ lib \ site - packages \ urllib3 \ util \ ssl_ py", line 384, in ssl_wrap_socket
Return the context. Wrap_socket (sock, server_hostname=server_hostname)
The File "D: \ Python \ Python38-32 \ lib \ SSL py", line 500, in wrap_socket
Return the self. Sslsocket_class. _create (
The File "D: \ Python \ Python38-32 \ lib \ SSL py", line 1040, in _create
Self. Do_handshake ()
The File "D: \ Python \ Python38-32 \ lib \ SSL py", line 1309, in do_handshake
Self. _sslobj. Do_handshake ()
SSL. SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get the local issuer certificate (_ssl. C: 1108)
During handling of the above exception, another exception occurred:
Traceback (the most recent call last) :
The File "D: \ Python \ Python38-32 \ lib \ site - packages \ requests \ adapters py", line 439, in the send
Resp=conn. Urlopen (
The File "D: \ Python \ Python38-32 \ lib \ site - packages \ urllib3 \ connectionpool py", line 726, in urlopen
Retries=retries. Increment (
The File "D: \ Python \ Python38-32 \ lib \ site - packages \ urllib3 \ util \ retry py", line 439, the increment in
Raise MaxRetryError (_pool, url, the error or ResponseError (cause))
Urllib3. Exceptions. MaxRetryError: HTTPSConnectionPool (host='data. Stats. Gov. Cn', the port=443) : Max retries exceeded with url:/easyquery. HTM? Cn=A01 (under Caused by SSLError (SSLCertVerificationError (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get the local issuer certificate (_ssl. C: 1108)')))
During handling of the above exception, another exception occurred:
Traceback (the most recent call last) :
The File "D:/MyData/zhoutao10/PycharmProjects/Numpy/test. The py", line 6, the in & lt; module>
The response=requests. Get (' https://data.stats.gov.cn/easyquery.htm? Cn=A01 'headers=headers, verify=' D: \ MyData \ zhoutao10 \ Desktop \ certificate of the National Bureau of Statistics. Pem ')
The File "D: \ Python \ Python38-32 \ lib \ site - packages/requests/API. Py", line 76, in the get
Return the request (' get 'url, params=params, * * kwargs)
The File "D: \ Python \ Python38-32 \ lib \ site - packages/requests/API. Py", line 61, in the request
Return the session. The request (method=method, url=url, * * kwargs)
The File "D: \ Python \ Python38-32 \ lib \ site - packages \ requests \ sessions py", line 542, in the request
Resp=self. Send (prep, * * send_kwargs)
The File "D: \ Python \ Python38-32 \ lib \ site - packages \ requests \ sessions py", line 655, in the send
R=adapter. Send (request, * * kwargs)
The File "D: \ Python \ Python38-32 \ lib \ site - packages \ requests \ adapters py", line 514, in the send
Raise SSLError (e, request=request)
Requests. Exceptions. SSLError: HTTPSConnectionPool (host='data. Stats. Gov. Cn', the port=443) : Max retries exceeded with url:/easyquery. HTM? Cn=A01 (under Caused by SSLError (SSLCertVerificationError (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get the local issuer certificate (_ssl. C: 1108)')))