接口测试cookies传参
import requests,json
def userLogin():
url = "http://192.168.1.56:6656/userM/userLogin"
payload = {"userID":"super","userPWD":"111111"}
headers = {
'Content-Type': 'application/json',
}
response = requests.request("POST", url, headers=headers, data=json.dumps(payload))
return (response.cookies)
def getStatistics():
url = "http://192.168.1.56:6656/statistics/getStatistics"
payload = {"algorithmID": "b0facafc-91c3-11ea-804a-04d9f5028075"}
headers = {
'Content-Type': 'application/json',
}
response = requests.request("POST", url, headers=headers, data=json.dumps(payload),cookies=userLogin())
return (json.loads(response.text)["dataNode"]['numByType'])