How to send a request by requests in Python
Editor to share with you how to send requests in Python requests, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!
1. Import Requests module.
> import requests
2. Try to get a web page.
Let's get Github's public timeline.
> r = requests.get ('https://github.com/timeline.json')
Now we have a Response object named r. We can get all the information we want from this object.
3. Requests's API means that all HTTP request types are obvious, send a HTTP POST request.
> r = requests.post ("http://httpbin.org/post")"
What about other HTTP request types: PUT, DELETE, HEAD, and OPTIONS? It's all the same simple:
> r = requests.put ("http://httpbin.org/put")>>> r = requests.delete (" http://httpbin.org/delete")>>> r = requests.head ("http://httpbin.org/get")>>> r = requests.options) (" http://httpbin.org/get") above is all the content of the article "how to send a request in Python". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!