🔨
This commit is contained in:
parent
a823d3afdd
commit
d478758b92
@ -41,9 +41,9 @@ def get_code(location):
|
|||||||
return code
|
return code
|
||||||
|
|
||||||
# 登录
|
# 登录
|
||||||
def login(user,password):
|
def login(_user, password):
|
||||||
url1 = "https://api-user.huami.com/registrations/+86" + user + "/tokens"
|
url1 = "https://api-user.huami.com/registrations/+86" + _user + "/tokens"
|
||||||
headers = {
|
_headers = {
|
||||||
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
|
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
|
||||||
"User-Agent": "MiFit/4.6.0 (iPhone; iOS 14.0.1; Scale/2.00)"
|
"User-Agent": "MiFit/4.6.0 (iPhone; iOS 14.0.1; Scale/2.00)"
|
||||||
}
|
}
|
||||||
@ -53,9 +53,9 @@ def login(user,password):
|
|||||||
"redirect_uri": "https://s3-us-west-2.amazonaws.com/hm-registration/successsignin.html",
|
"redirect_uri": "https://s3-us-west-2.amazonaws.com/hm-registration/successsignin.html",
|
||||||
"token": "access"
|
"token": "access"
|
||||||
}
|
}
|
||||||
r1 = requests.post(url1,data=data1,headers=headers,allow_redirects=False)
|
r1 = requests.post(url1, data=data1, headers=_headers, allow_redirects=False)
|
||||||
location = r1.headers["Location"]
|
|
||||||
try:
|
try:
|
||||||
|
location = r1.headers["Location"]
|
||||||
code = get_code(location)
|
code = get_code(location)
|
||||||
except:
|
except:
|
||||||
return 0, 0
|
return 0, 0
|
||||||
@ -73,7 +73,7 @@ def login(user,password):
|
|||||||
"grant_type": "access_token",
|
"grant_type": "access_token",
|
||||||
"third_name": "huami_phone",
|
"third_name": "huami_phone",
|
||||||
}
|
}
|
||||||
r2 = requests.post(url2,data=data2,headers=headers).json()
|
r2 = requests.post(url2, data=data2, headers=_headers).json()
|
||||||
login_token = r2["token_info"]["login_token"]
|
login_token = r2["token_info"]["login_token"]
|
||||||
# print("login_token获取成功!")
|
# print("login_token获取成功!")
|
||||||
# print(login_token)
|
# print(login_token)
|
||||||
@ -84,19 +84,18 @@ def login(user,password):
|
|||||||
return login_token, userid
|
return login_token, userid
|
||||||
|
|
||||||
# 主函数
|
# 主函数
|
||||||
def main(user, passwd, step):
|
def main(_user, _passwd, _step):
|
||||||
user = str(user)
|
_user = str(_user)
|
||||||
password = str(passwd)
|
password = str(_passwd)
|
||||||
step = str(step)
|
_step = str(_step)
|
||||||
if user == '' or password == '':
|
if _user == '' or password == '':
|
||||||
print("用户名或密码不能为空!")
|
print("用户名或密码不能为空!")
|
||||||
return "user and passwd not empty!"
|
return "user and passwd not empty!"
|
||||||
|
|
||||||
if step == '':
|
if _step == '':
|
||||||
print("已设置为随机步数(18000-25000)")
|
print("已设置为随机步数(18000-25000)")
|
||||||
step = str(random.randint(18000,25000))
|
_step = str(random.randint(18000, 25000))
|
||||||
login_token = 0
|
login_token, userid = login(_user, password)
|
||||||
login_token,userid = login(user,password)
|
|
||||||
if login_token == 0:
|
if login_token == 0:
|
||||||
print("登陆失败!")
|
print("登陆失败!")
|
||||||
return "login fail!"
|
return "login fail!"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user