Python Interface Automation 9-https request (SSL)

Source: Internet
Author: User
Tags ssl certificate

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.