During the test , A large amount of test data may be required , have access to Python Programming languages do a lot of interface requests for us
1, With post The way to request
import request # Leading package
re = requests.post(url="https://www.csdn.net",data={"a":1},headers={"token":"q1231"}) # add to url, Add request body, Add request headers
print(re.json()) # Return content json Format
print(re.text) # Return content text format
2, With get Method request for
import requests # Leading package
re = requests.get(url="https://www.csdn.net?a=1",headers={"a":1}) # add to url, Add request headers, the reason being that get request , So there is no need to add a request body, Requested parameter join url Just inside
print(re.json()) # Response content format