解决Python3 控制台输出InsecureRequestWarning的问题

196 阅读1分钟

问题描述

使用Python3.9的requests发送HTTPS请求,已经关闭认证(verify=False)情况下,控制台会输出以下错误:

InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: urllib3.readthedocs.io/en/latest/a…

解决办法

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

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