对于 requests 库中我们访问带有加密的 https 协议时通常会 ssl 报错, 我们一般会在后面加上 verify=False 取消 SSL 验证即可, 但是昨天博主遇到了加上这个还会报错
Python requests 移除 SSL 认证, 控制台输出 InsecureRequestWarning 取消方法.
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.get() 前面
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
来源: http://www.jianshu.com/p/6391d6de49ab