标签:color .com header har headers set admin sdi win
1 import requests 2 import json 3 4 plateform_base = ‘192.168.1.11:8082/platform‘ 5 6 7 token = ‘‘ 8 refreshToken = ‘‘ 9 10 ‘‘‘ 11 获取登录的token 12 ‘‘‘ 13 def GetToken(): 14 url = "http://{{plateform_base}}/auth/login" 15 16 payload = "{\"username\":\"18888888888\",\"password\":\"Admin@yxy\",\"orgName\":\"123\"}" 17 headers = { 18 ‘accept‘: "application/json, text/plain, */*", 19 ‘origin‘: "http://dev-test-parking.xianlixiang.com", 20 ‘user-agent‘: "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36", 21 ‘content-type‘: "application/json;charset=UTF-8", 22 ‘referer‘: "http://dev-test-parking.xianlixiang.com/", 23 ‘accept-encoding‘: "gzip, deflate", 24 ‘accept-language‘: "zh-CN,zh;q=0.8", 25 ‘cache-control‘: "no-cache", 26 ‘postman-token‘: "c388444f-0ee5-80a7-9f60-7bff932d9c5e" 27 } 28 url = url.replace(‘{{plateform_base}}‘, plateform_base) 29 30 response = requests.request("POST", url, data=payload, headers=headers) 31 32 print(response.text) 33 j = json.loads(response.text) 34 35 if j[‘code‘] == 0: 36 #字符串转换为字典 37 successdict = eval(str(j[‘data‘])) 38 token = successdict[‘token‘] 39 refreshToken = successdict[‘refreshToken‘] 40 print ‘Get Token End!‘
标签:color .com header har headers set admin sdi win
原文地址:http://www.cnblogs.com/Thriving-Heart/p/7735905.html