已更新于2022/12/28 目前可用
复制代码
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199import requests import json import time from datetime import datetime import pytz import hashlib import urllib3 import base64 from Crypto.Cipher import AES from Crypto.Util.Padding import pad from requests.packages.urllib3.exceptions import InsecureRequestWarning urllib3.disable_warnings() tz = pytz.timezone('Asia/Shanghai') class EncryptDate: def __init__(self, key): self.key = key self.length = AES.block_size self.aes = AES.new(self.key.encode("utf-8"), AES.MODE_ECB) self.unpad = lambda date: date[0:-ord(date[-1])] def fill_method(self, aes_str): pad_pkcs7 = pad(aes_str.encode('utf-8'), AES.block_size, style='pkcs7') return pad_pkcs7 def encrypt(self, encrData): res = self.aes.encrypt(self.fill_method(encrData)) msg = str(base64.b64encode(res), encoding="utf-8") return msg def decrypt(self, decrData): res = base64.decodebytes(decrData.encode("utf-8")) msg = self.aes.decrypt(res).decode("utf-8") return self.unpad(msg) # 登录 def login(user, pwd,t): global token, userId, roleKey url = "https://api.moguding.net:9000/session/user/v3/login" headers = { 'content-type': 'application/json; charset=utf-8' } data = { "captcha" : 'null', "device" : "android", "password": pwd, "loginType": "android", "t" : t, "uuid" : "", "version" : "5.3.0", "phone": user } r = requests.post(url, data=json.dumps(data), headers=headers, verify=False) j = json.loads(r.text) code = j['code'] name = j['data']['nikeName'] token = j['data']['token'] userId = j['data']['userId'] roleKey = j['data']['roleGroup'][0]['roleKey'] if code == 200: print('login sign successful,welcome~ ') else: print('login failed') # 获取学院信息 def getPlanByStu(): global planId sign = getPlanByStuSign() url = "https://api.moguding.net:9000/practice/plan/v3/getPlanByStu" headers = { 'content-type': 'application/json; charset=utf-8', "Host": "api.moguding.net:9000", "Accept-Language": "zh-CN,zh;q=0.8", "User-Agent": "Mozilla/5.0 (Linux; U; Android 7.1.2; zh-cn; SKW-A0 Build/N2G47H) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30", "roleKey": str(roleKey), "Sign": str(sign), "Authorization": str(token), "Accept-Encoding": "", "Cache-Control": "no-cache" } data = { "state": "" } r = requests.post(url, data=json.dumps(data), headers=headers) j = json.loads(r.text) j = json.loads(r.text) code = j['code'] planId = j['data'][0]['planId'] if code == 200: print('query successful!') else: print('query failed!') # 获取学院信息接口的sign def getPlanByStuSign(): screet = "3478cbbc33f84bd00d75d7dfa69e0daa" s = str(userId)+str(roleKey)+screet sign = getmd5(s) print("sign1====> "+str(sign)) return sign # md5加密 def getmd5(s): md = hashlib.md5() md.update(s.encode(encoding='utf-8')) get_md5 = md.hexdigest() return get_md5 # 获取签到sign为tosign_sign def get_tosign(address): # %Y-%m-%d %H:%M:%S times = datetime.fromtimestamp(int(time.time()), pytz.timezone('Asia/Shanghai')).strftime('%H') type = "" if int(times) < 12: # 早上打卡 type = "START" else: # 下午打卡 type = "END" s = "Android"+str(type)+str(planId)+str(userId) + str(address)+"3478cbbc33f84bd00d75d7dfa69e0daa" tosign_sign = getmd5(s) # print("sign2====> "+str(tosign_sign)) return tosign_sign # 去签到任务 def tosign(description, address, province, city, longitude, latitude): """ description:打卡备注 address:地址 province:省份 city:城市 longitude:经度 latitude:纬度 """ to_sign = get_tosign(address) # %Y-%m-%d %H:%M:%S times = datetime.fromtimestamp(int(time.time()), pytz.timezone('Asia/Shanghai')).strftime('%H') type = "" if int(times) < 12: # 早上打卡 type = "START" else: # 下午打卡 type = "END" url = "https://api.moguding.net:9000/attendence/clock/v2/save" data = { "device": "Android", "address": address, "t": "", "description": description, "country": "中国", "longitude": longitude, "latitude": latitude, "city": city, "province": province, "planId": planId, "type": type } headers = { 'content-type': 'application/json; charset=utf-8', "Host": "api.moguding.net:9000", "Accept-Language": "zh-CN,zh;q=0.8", "User-Agent": "Mozilla/5.0 (Linux; U; Android 7.1.2; zh-cn; SKW-A0 Build/N2G47H) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30", "Sign": str(to_sign), "Authorization": str(token), "Accept-Encoding": "", "Cache-Control": "no-cache" } r = requests.post(url, data=json.dumps(data), headers=headers) j = json.loads(r.text) j = json.loads(r.text) code = j['code'] if code == 200: print('sign successful!~') else: print('sign failed') def get_encrypt(s): eg = EncryptDate("23DbtQHR2UMbH6mJ") # key en = eg.encrypt(s) de = eg.decrypt(en) # 解密 res = base64.b64decode(en).hex() print(s+" ---> "+res) return res # 任务启动 def run(): # 填好配置,且不能注释下面调用的函数,否则报错. user = get_encrypt('这里写账号') # 账号 pwd = get_encrypt('这里写密码') # 密码 t = get_encrypt(str(int(round(time.time() * 1000)))) description = "打卡" province = "" # 实习所在省份 city = "" # 实习所在市区 longitude = "" # 经度 latitude = "" # 纬度 address = "" # 实习打卡所在的详细信息 login(user, pwd,t) getPlanByStu() get_tosign(address) tosign(description, address, province, city, longitude, latitude) # 云函数使用 def main_handler(event, context): run() return("------ end ------") if __name__ == '__main__': run()
最后
以上就是生动老虎最近收集整理的关于工学云打卡记录已更新于2022/12/28 目前可用的全部内容,更多相关工学云打卡记录已更新于2022/12/28内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复