时间:2022-08-19 09:52:17 | 栏目:Python代码 | 点击:次
默认情况下,启用SSL验证,如果无法验证SSL证书会导致:
requests.exceptions.SSLError: ("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')],)",)
解决办法:
# 在requests中加入verify=False res = requests.get(ur,verify=False)
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 InsecureRequestWarning)
解决办法:
from requests.packages.urllib3.exceptions import InsecureRequestWarning # 禁用安全请求警告 requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
requests.get(url,verify=False)
以前的12306证书不被认证
对于https协议
会有一个ssl证书的加密认证