-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlexin.py
156 lines (139 loc) · 4.98 KB
/
lexin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# -*- coding: utf8 -*-
'''
cron: 48 10,15 * * *
new Env('乐心刷步');
'''
import requests
import hashlib
import json
import time
import random
requests.packages.urllib3.disable_warnings
msg_all = "乐心健康\n\n"
def md5(code):
res=hashlib.md5()
res.update(code.encode("utf8"))
return res.hexdigest()
def get_information(mobile,password):
header = {
'Content-Type': 'application/json; charset=utf-8',
"User-Agent": "Dalvik/2.1.0 (Linux; U; Android 9; SM-G9500 Build/PPR1.180610.011)"
}
url="https://sports.lifesense.com/sessions_service/login?version=4.5&systemType=2"
datas = {
"appType":6,
"clientId":'8e844e28db7245eb81823132464835eb',
"loginName":str(mobile),
"password":md5(str(password)),
"roleType":0
}
response =requests.post(url,headers=header,data=json.dumps(datas))
return response.text
def update_step(step,information):
step =int(step)
url="https://sports.lifesense.com/sport_service/sport/sport/uploadMobileStepV2?version=4.5&systemType=2"
accessToken=json.loads(information)["data"]["accessToken"]
userId=json.loads(information)["data"]["userId"]
#print(json.loads(information))
#print(accessToken)
#print(userId)
#获取当前时间和日期
timeStamp=time.time()
localTime = time.localtime(timeStamp)
strTime = time.strftime("%Y-%m-%d %H:%M:%S", localTime)
print(strTime)
measureTime=strTime+","+str(int(timeStamp))
header = {
'Cookie': 'accessToken='+accessToken,
'Content-Type': 'application/json; charset=utf-8',
"User-Agent": "Dalvik/2.1.0 (Linux; U; Android 9; SM-G9500 Build/PPR1.180610.011)"
}
sport_datas = {
"list": [
{
"DataSource":2,
#"active":0,
"calories":str(int(step/4)),
#"dataSource":4,
"deviceId":"M_NULL",
"distance":str(int(step/3)),
"exerciseTime":0,
"isUpload":0,
"measurementTime":measureTime,
#"priority":0,
"step": str(step),
"type":2,
"updated":str(int(time.time()*1000)),
"userId":str(userId)
}]
}
result=requests.post(url,headers=header,data=json.dumps(sport_datas))
# print(result.text)
return result.text
def bind(information):
accessToken = json.loads(information)["data"]["accessToken"]
userId = json.loads(information)["data"]["userId"]
header = {
'Cookie': 'accessToken=' + accessToken,
'Content-Type': 'application/json; charset=utf-8',
"User-Agent": "Dalvik/2.1.0 (Linux; U; Android 9; SM-G9500 Build/PPR1.180610.011)"
}
def server_send(msg):
if sckey == '':
return
server_url = "https://sc.ftqq.com/" + str(sckey) + ".send"
data = {
'text': msg,
'desp': msg
}
requests.post(server_url, data=data)
def kt_send(msg):
if ktkey == '':
return
kt_url = 'https://push.xuthus.cc/send/'+str(ktkey)
data = ('步数刷取完成,请查看详细信息~\n'+str(msg)).encode("utf-8")
requests.post(kt_url, data=data)
def tg_send(msg):
send_text = 'https://api.telegram.org/bot' + str(bot_token) + '/sendMessage?chat_id=' + str(bot_chatID) + '&parse_mode=Markdown&text=' + msg
response = requests.get(send_text)
return response.json()
def execute_walk(phone,password,step):
information=get_information(phone,password)
bind(information)
update_result=update_step(step,information)
result=json.loads(update_result)["msg"]
if result == '成功':
msg = "刷新步数成功!此次刷取" + str(step) + "步。"
print(msg_all + msg)
server_send(msg_all + msg)
kt_send(msg_all + msg)
tg_send(msg_all + msg)
else:
msg = "刷新步数失败!请查看云函数日志。"
print(msg_all + msg)
server_send(msg_all + msg)
kt_send(msg_all + msg)
tg_send(msg_all + msg)
def main():
if phone and password and step != '':
execute_walk(phone, password, step)
else:
msg = "未填写账号密码,请在脚本中填入。"
print(msg_all + msg)
server_send(msg_all + msg)
kt_send(msg_all + msg)
tg_send(msg_all + msg)
# -- 配置 --
# ------------------------------
phone = '' # 登陆账号
password = '' # 密码
step = random.randint(19000,20000) # 随机19000-20000步数
sckey = '' # server酱key(可空)
ktkey = '' # 酷推key(可空)
bot_token = '' #在https://t.me/BotFather中查看创建的机器人token(可空)
bot_chatID = '' #在https://t.me/getuseridbot中获取的userid(可空)
# ------------------------------
def main_handler(event, context):
return main()
if __name__ == '__main__':
main()