Introduction: Requests is an HTTP library written in Python, based on urllib and using the Apache2 Licensed open source protocol. It is more convenient than urllib, can save us a lot of work, and fully meet the HTTP testing needs. The philosophy of Requests is developed around the idiom of PEP 20, so it is more Pythoner than urllib.
1. Request method type
1. Get request: requests.get('url')
2. Post request: requests.post("url/post")
3. Put request: requests.put("url/put")
4. Delete request: requests. delete("url/delete")
5. Head request: requests.head("url/get")
6. Options request: requests.options("url/get"), etc.
Today we will explain how to perform interface testing of get and post methods.
Two, get request
First quote the requests library and json library, because we are using requests for interface testing.
Check the results
Three, post request
The difference between post request and get request is that the post request needs to pass the body parameter
This is how python implements get and post interface requests
You can also use tools for interface testing, such as the domestic interface testing tool apipost
Use apipost for get request
Make a post request
It can also generate interface documents in various formats such as: word format interface documents
Download URL of domestic interface tool apipost:https://www.apipost.cn