39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
|
|
#!/user/bin/python
|
|||
|
|
#-*-coding:utf-8-*-
|
|||
|
|
import requests
|
|||
|
|
import json
|
|||
|
|
#获取密码加密信息
|
|||
|
|
def encryptpwd():
|
|||
|
|
url1 = "http://192.168.44.71:8080/v1/user/encryptpwd"
|
|||
|
|
content = {"password":"1"}
|
|||
|
|
web = requests.get(url=url1,params=content)
|
|||
|
|
#print(web.text)
|
|||
|
|
ty = web.text
|
|||
|
|
a = json.loads(ty)
|
|||
|
|
#print(a["data"]['encryptpwd'])
|
|||
|
|
encryptpwd = a["data"]['encryptpwd']
|
|||
|
|
return encryptpwd
|
|||
|
|
#获取token
|
|||
|
|
def token():
|
|||
|
|
url2 = "http://192.168.44.71:8080/v1/user/login"
|
|||
|
|
content = {"username":"lyf","password":encryptpwd(),"authMode":1}
|
|||
|
|
web = requests.post(url=url2,params=content)
|
|||
|
|
#print(web.text)
|
|||
|
|
ty1 = web.text
|
|||
|
|
a1 = json.loads(ty1)
|
|||
|
|
token = a1["data"]["token"]
|
|||
|
|
return token
|
|||
|
|
#获取索引值
|
|||
|
|
def index1(id):
|
|||
|
|
url3 = "http://192.168.44.71/v1/user/login/restictions"
|
|||
|
|
headers = {"Content-Type":"application/json;charset=UTF-8","Authorization":token()}
|
|||
|
|
web = requests.get(url=url3,headers=headers)
|
|||
|
|
#print(web.text)
|
|||
|
|
ty2 = web.text
|
|||
|
|
a2 = json.loads(ty2)
|
|||
|
|
loginAddrWhitelist = a2["data"]["list"][0]["loginAddrWhitelist"]
|
|||
|
|
index2=loginAddrWhitelist.index(id)
|
|||
|
|
return index2
|
|||
|
|
if __name__ == '__main__':
|
|||
|
|
index1(id)
|