current position:Home>Python requests solves the problem that opening the packet capture tool can also run automated scripts and cancel the insecrerequestwarning output from the console

Python requests solves the problem that opening the packet capture tool can also run automated scripts and cancel the insecrerequestwarning output from the console

2022-02-02 15:05:05 adorable_

   Running Python+requests+pytest Interface automation script , Such as opening the bag capturing tool , Will report a mistake :HTTPSConnectionPool(x):Max retries(Caused by SSLError).
   One of the simplest solutions is to close the packet capture tool , Of course, there is the use of code removal SSL authentication , The way of implementation is :

import requests
response = requests.get(url='', verify=False)

   Use requests Set remove SSL At the time of certification , After running the use case, the console will report the following warning :
 Insert picture description here
Although this does not affect the use of , But the little partner with OCD will be very upset , For example, I o(╥﹏╥)o
To find the information , There are two solutions found :

#  The first one is 
from requests.packages.urllib3.exceptions import InsecureRequestWarning
#  Disable security request warning 
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
resp = requests.get(url, verify=False)

#  The second kind 
import requests
requests.packages.urllib3.disable_warnings()
resp = requests.get(url, verify=False)

The actual result :
 Insert picture description here
Run the use case again , You won't report a warning for each use case

copyright notice
author[adorable_],Please bring the original link to reprint, thank you.
https://en.pythonmana.com/2022/02/202202021505023255.html

Random recommended