如何禁用 InsecureRequestWarning: Unverified HTTPS request is being made.

如果你使用 requests 或 urllib3,禁用 SSL 验证的请求将打印此警告:

insecure_request_warning.txt
/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py:851: 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
  InsecureRequestWarning)

如果你想禁用此警告并且你不能直接启用验证,添加此代码

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

到你的 Python 文件的顶部。


Check out similar posts by category: Python