0%

python3 使用requests发送未进验证的ssl请求警告提示

python3 使用requests发送未进验证的ssl请求警告提示:

image-20230831171649520

使用起来其实,无伤大雅,但是一排红字,就是有点难看。消除吧!

import requests

url = "xxx"
response = requests.get(url)
print(response.text)

# 返回内容:
/site-packages/urllib3/connectionpool.py:1095: InsecureRequestWarning: Unverified HTTPS request is being made to host '127.0.0.1'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings
warnings.warn(

解决方法:

在代码中添加以下代码即可解决:

import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)