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!