brief introduction :Requests Yes, it is Python Language writing , be based on urllib, use Apache2 Licensed Open source protocol HTTP library . It is better than urllib It is more convenient , Can save us a lot of work , Completely satisfied HTTP Test requirements .Requests Our philosophy is based on PEP 20 The idioms are developed for the center , So it's better than urllib more Pythoner.
One 、 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're going to show you how to do it get、post Method interface test .
Two 、get request
First quote requests Kuhe json library , Because we're using requests For interface testing .
Check out the results
3、 ... and 、post request
post Request and get The difference between requests is that post The request needs to be delivered body Parameters
This is it. python Realization get、post Interface request method
You can also use tools for interface testing , For example, domestic interface testing tools apipost
Use apipost Conduct get request
Conduct post request
You can also generate interface documents in various formats, such as :word Format interface document
Domestic interface tools apipost Download address :https://www.apipost.cn