Python的Request请求跳过认证及禁用警告

1.跳过认证

在使用python做测试测试的时候,因为认证报错,可以添加verify=False跳过认证,如下:

2.禁用警告

此时,代码运行不受影响,请求会成功,但结果会报错:

不影响运行,但感觉不舒服,此时在顶部导入:

from requests.packages.urllib3.exceptions import InsecureRequestWarning

在请求前加上代码:

requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
 
原文地址:https://www.cnblogs.com/Jollyxi/p/7872969.html