Python接口自动化
1.项目流程:注册-》登录-》充值
登录会产生cookies,充值需要用到登录产生的cookies才可以充值成功
代码如下
import requests#注册# register_url=‘testlink/register‘# register_data={"mobilephone":"15950123333","pwd":"123456","regname":"Mar"}# res=requests.get(register_url,register_data)# print("text解析结果",res.text)# print("text解析结果",res.json())#登录login_url=‘testlink/login‘login_data={"mobilephone":"15950123333","pwd":"123456"}res_login=requests.get(login_url,login_data)print("text解析结果",res_login.text)print("text解析结果",res_login.json())#充值方法一recharge_url=‘testlink/recharge‘recharge_data={"mobilephone":"15950123333","amount":"12"}# res_recharge=requests.get(recharge_url,recharge_data,cookies=res_login.cookies)# print("text解析结果",res_recharge.text)# print("text解析结果",res_recharge.json())#充值方法二,不用cookies,还可以用sessions=requests.session()login_res=s.get(login_url,params=login_data)recharge_res=s.post(recharge_url,recharge_data)print("充值的结果是: ",recharge_res.json())
相关推荐
ALiDan 2020-06-11
Catastrophe 2020-05-30
BlueSkyUSC 2020-03-08
zhujuyu 2020-02-12
gongruitao 2020-01-23
aweilark 2020-01-09
tiankele0 2020-01-05
四叶草 2020-01-04
xiaoyezihanghui 2019-12-25
四叶草 2019-12-25
似水流年梦 2019-12-19
xiaoxiaoniaoer 2019-12-01
ITxiaobaibai 2019-11-25
张艳秋 2019-11-18
xiyouiOS 2015-06-02
javaraylu 2019-11-10
Qimingweikun 2019-11-04
StevenSun空间 2019-10-22