Python3之關閉SSL證書驗證
阿新 • • 發佈:2019-01-07
報錯資訊:
Traceback (most recent call last):
File "D:\Python36\lib\site-packages\urllib3\contrib\pyopenssl.py", line 441, in wrap_socket
cnx.do_handshake()
File "D:\Python36\lib\site-packages\OpenSSL\SSL.py", line 1806, in do_handshake
self._raise_ssl_error(self._ssl, result)
File "D:\Python 36\lib\site-packages\OpenSSL\SSL.py", line 1546, in _raise_ssl_error
_raise_current_error()
File "D:\Python36\lib\site-packages\OpenSSL\_util.py", line 54, in exception_from_error_queue
raise exception_type(errors)
OpenSSL.SSL.Error: [('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')]
During handling of the above exception, another exception occurred:
因為網址使用了https,所以經過代理時會報錯;
解決方案:
#引數:verify=False
html = requests.get(item_url, headers=headers, verify=False)
# print(html.content)
Done!!!