python3中Requests将verify设置为False后,取消警告的方式

import requests
resp = requests.get('https://www.***.com', verify=False)

调用成功但是会有如下警告信息:

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)

解决方法一:

import requests
logging.captureWarnings(True)

解决方法二:

from requests.packages.urllib3.exceptions import InsecureRequestWarning
# 禁用安全请求警告
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
 
 
posted @ 2019-07-23 17:35  LCX测试小姐姐  阅读(5334)  评论(0编辑  收藏  举报