警告信息
/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py:986: InsecureRequestWarning: Unverified HTTPS request is being made to host 'www.baidu.com'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecureRequestWarning,

解决方法
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
res = requests.get(url, timeout=timeout, stream=True, verify=False, allow_redirects=False)
print(res.__dict__)
本文介绍如何在使用Python的requests库时,禁用因未验证HTTPS请求而产生的InsecureRequestWarning警告。通过导入requests及urllib3的InsecureRequestWarning,并调用disable_warnings方法,可以避免在代码运行时出现此类警告。
1280

被折叠的 条评论
为什么被折叠?



