🔨
This commit is contained in:
parent
d478758b92
commit
cb54dcc13f
@ -41,9 +41,9 @@ def get_code(location):
|
||||
return code
|
||||
|
||||
# 登录
|
||||
def login(_user, password):
|
||||
url1 = "https://api-user.huami.com/registrations/+86" + _user + "/tokens"
|
||||
_headers = {
|
||||
def login(user,password):
|
||||
url1 = "https://api-user.huami.com/registrations/+86" + user + "/tokens"
|
||||
headers = {
|
||||
"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8",
|
||||
"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",
|
||||
"token":"access"
|
||||
}
|
||||
r1 = requests.post(url1, data=data1, headers=_headers, allow_redirects=False)
|
||||
try:
|
||||
r1 = requests.post(url1,data=data1,headers=headers,allow_redirects=False)
|
||||
location = r1.headers["Location"]
|
||||
try:
|
||||
code = get_code(location)
|
||||
except:
|
||||
return 0,0
|
||||
@ -73,7 +73,7 @@ def login(_user, password):
|
||||
"grant_type":"access_token",
|
||||
"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"]
|
||||
#print("login_token获取成功!")
|
||||
#print(login_token)
|
||||
@ -84,18 +84,19 @@ def login(_user, password):
|
||||
return login_token,userid
|
||||
|
||||
# 主函数
|
||||
def main(_user, _passwd, _step):
|
||||
_user = str(_user)
|
||||
password = str(_passwd)
|
||||
_step = str(_step)
|
||||
if _user == '' or password == '':
|
||||
def main(user, passwd, step):
|
||||
user = str(user)
|
||||
password = str(passwd)
|
||||
step = str(step)
|
||||
if user == '' or password == '':
|
||||
print("用户名或密码不能为空!")
|
||||
return "user and passwd not empty!"
|
||||
|
||||
if _step == '':
|
||||
if step == '':
|
||||
print ("已设置为随机步数(18000-25000)")
|
||||
_step = str(random.randint(18000, 25000))
|
||||
login_token, userid = login(_user, password)
|
||||
step = str(random.randint(18000,25000))
|
||||
login_token = 0
|
||||
login_token,userid = login(user,password)
|
||||
if login_token == 0:
|
||||
print("登陆失败!")
|
||||
return "login fail!"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user