轉載 Python3之關閉SSL證書驗證
html
轉載 Python requests 移除SSL認證,控制檯輸出InsecureRequestWarning取消方法安全
報錯信息:socket
1 Traceback (most recent call last): 2 File "D:\Python36\lib\site-packages\urllib3\contrib\pyopenssl.py", line 441, in wrap_socket 3 cnx.do_handshake() 4 File "D:\Python36\lib\site-packages\OpenSSL\SSL.py", line 1806, in do_handshake 5 self._raise_ssl_error(self._ssl, result) 6 File "D:\Python36\lib\site-packages\OpenSSL\SSL.py", line 1546, in _raise_ssl_error 7 _raise_current_error() 8 File "D:\Python36\lib\site-packages\OpenSSL\_util.py", line 54, in exception_from_error_queue 9 raise exception_type(errors) 10 OpenSSL.SSL.Error: [('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')] 11 12 During handling of the above exception, another exception occurred:
解決方法url
1 #參數:verify=False 2 html = requests.get(item_url, headers=headers, verify=False) 3 # print(html.content)
今天遇到在requests設置移除SSL認證的時候,控制檯會拋出如下警告:spa
1 C:\Python27\lib\site-packages\requests\packages\urllib3\connectionpool.py:843: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings 2 InsecureRequestWarning) 3 C:\Python27\lib\site-packages\requests\packages\urllib3\connectionpool.py:843: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings 4 InsecureRequestWarning)
解決方法.net
1 from requests.packages.urllib3.exceptions import InsecureRequestWarning 2 # 禁用安全請求警告 3 requests.packages.urllib3.disable_warnings(InsecureRequestWarning)