InsecureRequestWarning: Unverified HTTPS request is being made to host (https请求警告)

报错信息如下:

E:\install_path\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py:981: InsecureRequestWarning: Unverified HTTPS request is being made to host 'xxx.xxx.xxx.xxx'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  warnings.warn(

解决方案:

1、方法1:
import requests

# 处理https警告
requests.packages.urllib3.disable_warnings()

res = requests.post(url, data=data, verify=False)  # verify=False,不使用SSL证书
print(res.text)


2、方法2:
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning

# 处理https警告
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

res = requests.post(url, data=data, verify=False)  # verify=False,不使用SSL证书
print(res.text)
上一篇:全干工程师


下一篇:制作类似ThinkPHP框架中的PATHINFO模式功能(二)