python接口自动化测试-参数关联接口
取上一个接口的响应中的session
# 导包 import requests import re #接口地址 url2 = "http://192.168.103.106:1080/webtours/nav.pl?in=home" s = requests.session()# 为了保持和下一个接口建立相同的连接通道 res = s.get(url2) # print(res.text) usersession = re.findall(r'name=userSession value=(.+?)>',res.text) print(usersession) # para2 ={"in":"home"} # 接口地址 url ="http://192.168.103.106:1080/webtours/login.pl" para ={"userSession":usersession[0],"username":"jojo","password":"bean","login.x":"54","login.y":"11","login":"Login","JSFormSubmit":"off"} r = s.post(url,data=para) # 发送post请求 # r = requests.post(url,data=para) print(r.text)
完