doina

一个小菜鸟运维工程师.

pytnon3 request模块忽略ssl证书错误

python3 报错如下:

#此错误主要是因为证书中的server那么和请求的域名地址不匹配导致 
/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py:857: 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

#在request.get中关闭证书验证verify=False
在request.get(url, timeout=30, verify=False)

#在代码块中添加以下代码
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
点赞

发表评论

邮箱地址不会被公开。

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据