Simple example of using requests and https in python, pythonrequests

Source: Internet
Author: User

Simple example of using requests and https in python, pythonrequests

Requests is a very small and comprehensive library. It can easily write programs that interact with the server. Today, a problem occurs. when interacting with the server, the url starts with https, both are encrypted with ssl, So that you cannot access the url starting with http as before.

After checking some information, you can configure the file for ssl verification as follows:

Res = requests. get ('https: // 127.0.0.1: 5503/login', cert = ('./server. crt', './server. key. unsecure '))

After it can be run, the verification fails. My key file is server. key. unsecure, which is specially generated to prevent password input. For the generation method, refer to this post and click open link.

If I change the key file to server. key, I need to manually enter the password even though the verification is successful. This is obviously not what I want.

Finally, an ugly but effective method is adopted, which is not verified.

Session = requests. session () data = {'username': 'admin', 'Password': 'admin'} res = session. post ('https: // 127.0.0.1: 5503/login', verify = False, data = data)

Setting verify to False leads to this issue.

Summary

This article describes all the simple examples of using requests and https in python. If you are interested, you can continue to refer to other related topics on this site. If you have any shortcomings, please leave a message. Thank you for your support!

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.