sws_接口自动化_demo
登录接口获取token:
1 import requests 2 import json 3 4 def get_token(username, password): 5 host = "https://sws.nbhtxx.com.cn" 6 data = { 7 'userid': username, 8 'password': password, 9 'param': 'login' 10 } 11 r = requests.post(host + "/entry", data=data, timeout=1) 12 print("获取token请求地址是:", r.url) 13 ty = r.text 14 a = json.loads(ty) 15 b = json.loads(a.get('Data')) 16 sws_token = b.get('token') 17 return sws_token 18 19 #调取get_token的方法: 20 # if __name__ == '__main__': 21 # a = get_token('testswss', '12345678') 22 # print("sws_token是:", a)
企业信息列表接口:
1 import requests 2 import json 3 from Get_Token import get_token 4 def qyxx_getQyxxList(page=1, pageSize=10, qysh='', name='', swsid=''): 5 host = "https://sws.nbhtxx.com.cn" 6 token = get_token("testsws2", "12345678") 7 data = { 8 'page': page, 9 'pageSize': pageSize, 10 'qysh': qysh, 11 'name': name, 12 'swsid': swsid, 13 'param': 'qyxx_getQyxxList', 14 'token': token 15 } 16 r = requests.get(host + '/entry', params=data, timeout=1) 17 print('企业变更查询请求地址是:', r.url) 18 result = r.json() 19 return result 20 21 22 #调用qyxx_getQyxxList方法: 23 # if __name__ == '__main__': 24 # a = qyxx_getQyxxList(1, 20) 25 # print(a)