问题:
使用Python3 requests发送HTTPS请求,已经关闭认证(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
解决方法:
在代码中添加以下代码即可解决:
1 import urllib3
2 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
Python2添加如下代码即可解决:
1 from requests.packages.urllib3.exceptions import InsecureRequestWarning
2 # 禁用安全请求警告
3 requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
requests.exceptions.SSLError: HTTPSConnectionPool(host='XXX', port=443)
解决方法如下:
1、先检查是否已安装requests的依赖安装包:
pip install cryptography
pip install pyOpenSSL
pip install certifi
2、如果已经安装依赖安装包,还会报错,则在请求后面加上verify=False就可以
|