Objective
Originally the latest requests Library V2.13.0 is to support HTTPS requests, but generally write scripts, we will use the Capture Package tool fiddler, this time will be reported: Requests.exceptions.SSLError: [Ssl:certificate _verify_failed] Certificate VERIFY FAILED (_ssl.c:590)
Small Series Environment:
python:2.7.12
requests:2.13.0
fiddler:v4.6.2.0
First, SSL issues
1. Do not enable fiddler, direct HTTPS request, there is no SSL problem (that is, do not want to see the SSL problem, turn off the fiddler line)
2. Start the Fiddler capture package, this error will occur: Requests.exceptions.SSLError: [ssl:certificate_verify_failed] CERTIFICATE VERIFY FAILED (_ ssl.c:590)
Second, verify parameter setting
1.Requests Request Default Verify=true
2. If you set verify to False,requests, you can also ignore the authentication of SSL certificate
3. However, there will still be two lines of warning
Third, ignoring warning
1. Some small partners have obsessive-compulsive disorder to see red heart panic, here add two lines of code can ignore the warning, the eye is not net!
2. Reference code:
# Coding:utf-8
Import requests
# Disable Security Request warning
From requests.packages.urllib3.exceptions import insecurerequestwarning
Requests.packages.urllib3.disable_warnings (insecurerequestwarning)
url = "Https://passport.cnblogs.com/user/signin"
headers = {
"User-agent": "mozilla/5.0 (Windows NT 10.0; WOW64; rv:44.0) gecko/20100101 firefox/44.0 "
}
r = Requests.get (URL, headers=headers, verify=false)
Print (R.status_code)
Interested in Python interface automation, you can add Python interface Automation QQ Group: 226296743
You can also pay attention to my personal public number:
Python Interface Automation 9-https request (SSL)