- eg:
import requests url = 'https://mip.tutumanhua.com/' headers = { 'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.70 Safari/537.36' } res = requests.get(url=url,headers=headers) print(res)
- 出现SSLError-->证书验证有问题,添加verify参数为False,禁止证书验证,就不会抛异常了
-
import requests url = 'https://mip.tutumanhua.com/' headers = { 'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.70 Safari/537.36' } #出现SSLError -->证书验证有问题,添加verify参数为False,禁止证书验证,就不会抛异常了 res = requests.get(url=url,headers=headers,verify=False) print(res)
-
- 即使添加了verify参数还是产生警告下面这行代码避免产生警告的
- requests.packages.urllib3.disable_warnings()
-
import requests url = 'https://mip.tutumanhua.com/' headers = { 'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.70 Safari/537.36' } #即使添加了verify参数,但是还以产生警告,下面这行代码避免产生警告的 requests.packages.urllib3.disable_warnings() #出现SSLError -->证书验证有问题,添加verify参数为False,禁止证书验证,就不会抛异常了 res = requests.get(url=url,headers=headers,verify=False) print(res)