• 问题描述

使用Python3的requests发送HTTPS请求,关闭认证(verify=False)情况下,控制台会输出警告。

"""
InsecureRequestWarning: Unverified HTTPS request is being made.

Adding certificate verification is strongly advised.
"""
  • 解决办法

在语句前加上以下代码即可不会输出警告。

from urllib3 import disable_warnings
from urllib3.exceptions import InsecureRequestWarning

# 忽略HTTPS警告
disable_warnings(InsecureRequestWarning)