# coding=utf-8 """ =================================== 深圳多测师信息技术有限公司 作者:多测师-小程 日期:2023年03月30日 =================================== """ #关联接口:上一个接口的返回参数作为下一个接口的入参 # import requests # import re # class Province(): # def get_province(self): # url='http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getSupportProvince' # res=requests.post(url=url) # result=res.text #不是json格式的字符串不能用json函数进行转化成字典 # all=re.findall('<string>(.+)</string>',result) #拿到省份是一个列表的形式 # return all # # def get_city(self,index): # url='http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getSupportCity' # data={'byProvinceName':self.get_province()[index]} # res=requests.post(url=url,data=data) # result=res.text # print(result) # if __name__ == '__main__': # a=Province() # a.get_province() # a.get_city(8) import requests class Yshop(): def code(self): '''获取uuid''' url='http://manage.duoceshi.com/auth/code' res=requests.get(url=url) result=res.json()['uuid'] return result def login(self): url='http://manage.duoceshi.com/auth/login' data={ "username": "admin", "password": "D4xcjr8mzOW78smR3tK169GcCx9UPfBoHHae9qEwke/ku/kwkl3X2lxUClUbcHly6lZHwAxGrStew4D5D5OnQA==", "code": "8888", "uuid": self.code() } header={'Content-Type':'application/json'} res=requests.post(url=url,json=data,headers=header) result=res.json()['token'] return result def build(self): url='http://manage.duoceshi.com/api/menus/build' header={'Authorization':self.login()} res = requests.get(url=url,headers=header) result=res.json() print(result) if __name__ == '__main__': a=Yshop() # a.code() # a.login() a.build()
标签:__,get,python,res,self,接口,url,result,自动化 From: https://www.cnblogs.com/jjm414/p/17335093.html