forked from OreosLab/checkinpanel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathck_womail.py
480 lines (468 loc) · 22.6 KB
/
ck_womail.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
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
# -*- coding: utf-8 -*-
"""
cron: 36 13 * * *
new Env('联通沃邮箱');
"""
import json
import re
import requests
from notify_mtr import send
from utils import get_data
class WoMail:
def __init__(self, check_items):
self.check_items = check_items
self.user_agent = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3868.400 QQBrowser/10.8.4394.400"
def login(self, womail_url):
try:
url = womail_url
headers = {"User-Agent": self.user_agent}
res = requests.get(url=url, headers=headers, allow_redirects=False)
set_cookie = res.headers["Set-Cookie"]
cookies = re.findall("YZKF_SESSION.*?;", set_cookie)[0]
if "YZKF_SESSION" in cookies:
return cookies
else:
print("沃邮箱获取 cookies 失败")
return None
except Exception as e:
print("沃邮箱错误:", e)
return None
def nyan_task(self, cookies, pause21days=True):
msg = []
headers = {
"User-Agent": self.user_agent,
"Cookie": cookies,
}
try:
url = "https://nyan.mail.wo.cn/cn/sign/index/userinfo.do?rand=0.8897817905278955"
res = requests.post(url=url, headers=headers)
result = res.json()
wxname = result.get("result").get("wxName")
usermobile = result.get("result").get("userMobile")
keep_sign = result["result"]["keepSign"]
msg.append(
{
"name": "帐号信息",
"value": f"{wxname} - {usermobile[:3]}****{usermobile[-4:]}",
}
)
except Exception as e:
keep_sign = 0
msg.append({"name": "帐号信息", "value": str(e)})
try:
if pause21days and keep_sign >= 21:
msg.append({"name": "每日签到", "value": f"昨日为打卡{keep_sign}天,今日暂停打卡"})
else:
url = "https://nyan.mail.wo.cn/cn/sign/user/checkin.do?rand=0.913524814493383"
res = requests.post(url=url, headers=headers).json()
result = res.get("result")
if result == -2:
msg.append({"name": "每日签到", "value": f"已签到 {keep_sign} 天"})
elif result is None:
msg.append({"name": "每日签到", "value": "签到失败"})
else:
msg.append({"name": "每日签到", "value": f"签到成功~已签到{result}天!"})
except Exception as e:
msg.append({"name": "每日签到", "value": str(e)})
try:
url = (
"https://nyan.mail.wo.cn/cn/sign/user/doTask.do?rand=0.8776674762904109"
)
data_params = {
"每日首次登录手机邮箱": {"taskName": "loginmail"},
"去用户俱乐部逛一逛": {"taskName": "club"},
"小积分抽大奖": {"taskName": "clubactivity"},
"每日答题赢奖": {"taskName": "answer"},
"下载沃邮箱": {"taskName": "download"},
}
for key, data in data_params.items():
try:
res = requests.post(url=url, data=data, headers=headers).json()
result = res.get("result")
if result == 1:
msg.append({"name": key, "value": "做任务成功"})
elif result == -1:
msg.append({"name": key, "value": "任务已做过"})
elif result == -2:
msg.append({"name": key, "value": "请检查登录状态"})
else:
msg.append({"name": key, "value": "未知错误"})
except Exception as e:
msg.append({"name": key, "value": str(e)})
except Exception as e:
msg.append({"name": "执行任务错误", "value": str(e)})
return msg
def club_task(self, womail_url, pause21days=True):
msg = []
userdata = re.findall("mobile.*", womail_url)[0]
url = "https://club.mail.wo.cn/clubwebservice/?" + userdata
headers = {"User-Agent": self.user_agent}
try:
res = requests.get(url=url, headers=headers, allow_redirects=False)
set_cookie = res.headers["Set-Cookie"]
cookies = re.findall("SESSION.*?;", set_cookie)[0]
if "SESSION" in cookies:
headers = {
"User-Agent": self.user_agent,
"Cookie": cookies,
"Referer": "https://club.mail.wo.cn/clubwebservice/club-user/user-info/mine-task",
}
# 获取账号信息
try:
url = "https://club.mail.wo.cn/clubwebservice/club-user/user-info/get-user-score-info/"
res = requests.get(url=url, headers=headers)
result = res.json()
integraltotal = result.get("integralTotal")
msg.append({"name": "当前积分", "value": f"{integraltotal}"})
task_data = [
# 签到任务
{
"resourceName": "每日签到(积分)",
"url": "https://club.mail.wo.cn/clubwebservice/club-user/user-sign/create?channelId=",
},
# 积分任务
{
"irid": 539,
"resourceName": "参与俱乐部活动",
"resourceFlag": "Web_canyujulebuhuodong+2jifen",
"scoreNum": 1,
"scoreResourceType": "add",
"attachData": '{"1":"每天只增加一次积分"}',
"description": "参与俱乐部活动+1积分",
"sourceType": 0,
"link": '{"jumpLink":"https://club.mail.wo.cn/clubwebservice/club-index/activity-scope?currentPage=activityScope"}',
"taskState": 1,
"show": True,
},
{
"irid": 545,
"resourceName": "俱乐部积分兑换",
"resourceFlag": "Web_jifenduihuan+2jifen",
"scoreNum": 1,
"scoreResourceType": "add",
"attachData": '{"1":"每天只增加一次积分"}',
"description": "俱乐部积分兑换+1积分",
"sourceType": 0,
"link": '{"jumpLink":"https://club.mail.wo.cn/clubwebservice/score-exchange/into-score-exchange?currentPage=js-hover"}',
"taskState": 1,
"show": True,
},
# 成长值任务
{
"irid": 254,
"resourceName": "参与俱乐部活动",
"resourceFlag": "activity-web",
"scoreNum": 1,
"scoreResourceType": "add",
"attachData": '{"limit":"true","每日限定几次":"1次"}',
"description": "参与俱乐部活动",
"sourceType": 1,
"link": '{"jumpLink":"https://club.mail.wo.cn/clubwebservice/club-index/activity-scope?currentPage=activityScope"}',
"taskState": 0,
"show": True,
},
{
"irid": 561,
"resourceName": "俱乐部积分兑换",
"resourceFlag": "Web_jifenduihuan+5chengzhangzhi",
"scoreNum": 1,
"scoreResourceType": "add",
"attachData": '{"limit":"true","每日限定几次":"1次"}',
"description": "俱乐部积分兑换+1成长值",
"sourceType": 1,
"link": '{"jumpLink":"https://club.mail.wo.cn/clubwebservice/score-exchange/into-score-exchange?currentPage=js-hover"}',
"taskState": 0,
"show": True,
},
]
for task_item in task_data:
resource_name = task_item["resourceName"]
try:
if "每日签到" in resource_name:
record_url = "https://club.mail.wo.cn/clubwebservice/club-user/user-sign/query-continuous-sign-record"
record_res = requests.get(
url=record_url, headers=headers
).json()
if len(record_res):
new_continuous_day = record_res[0].get(
"newContinuousDay"
)
else:
new_continuous_day = 0
if pause21days and new_continuous_day >= 21:
msg.append(
{
"name": resource_name,
"value": f"昨日为打卡{new_continuous_day}天,今日暂停打卡",
}
)
else:
url = task_item["url"]
res = requests.get(url=url, headers=headers).json()
result = res.get("description")
if "success" in result:
continuous_day = json.loads(res["data"])[
"continuousDay"
]
msg.append(
{
"name": resource_name,
"value": f"签到成功~已连续签到{continuous_day}天!",
}
)
else:
if "您今天已签到" in result:
msg.append(
{
"name": resource_name,
"value": f"签到成功~已连续签到{new_continuous_day}天!",
}
)
else:
msg.append(
{"name": resource_name, "value": result}
)
else:
resource_flag = task_item["resourceFlag"]
resource_flag = resource_flag.replace("+", "%2B")
url = (
f"https://club.mail.wo.cn/clubwebservice/growth/addGrowthViaTask?resourceType={resource_flag}"
if task_item["sourceType"]
else f"https://club.mail.wo.cn/clubwebservice/growth/addIntegral?resourceType={resource_flag}"
)
res = requests.get(url=url, headers=headers).json()
result = res.get("description")
msg.append({"name": resource_name, "value": result})
except Exception as e:
msg.append({"name": resource_name, "value": str(e)})
except Exception as e:
msg.append({"name": "沃邮箱俱乐部", "value": str(e)})
else:
msg.append({"name": "沃邮箱俱乐部", "value": "获取 SESSION 失败"})
except Exception as e:
print("沃邮箱俱乐部获取 COOKIES 失败", e)
msg.append({"name": "沃邮箱俱乐部", "value": "获取 COOKIES 失败"})
return msg
def core_task(self, phone, password):
msg = []
try:
url = "https://mail.wo.cn/coremail/s/json?func=user:login"
headers = {"User-Agent": "okhttp/${project.version}"}
data_json = {"uid": str(phone), "password": str(password)}
response = requests.post(
url=url, headers=headers, data=json.dumps(data_json)
)
sid = re.findall('"sid":"(.*?)"', response.text)[0]
set_cookie = response.headers["Set-Cookie"]
cookie = re.findall("Coremail.*?;", set_cookie)[0]
cookie = cookie + "Coremail.sid=" + str(sid) + ";"
if "Coremail" not in cookie:
msg.append({"name": "Coremail", "value": "沃邮箱获取 sid,Coremail 失败"})
return msg
cookies = cookie + "domain=mail.wo.cn;"
headers = {
"User-Agent": self.user_agent,
"Cookie": cookies,
"Accept": "text/x-json",
"Content-Type": "text/x-json",
"X-CM-SERVICE": "PHONE",
"Origin": "https://mail.wo.cn",
"X-Requested-With": "com.asiainfo.android",
"Sec-Fetch-Site": "same-origin",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Dest": "empty",
}
# 增加积分
integral_data = {
"每日登录": "login",
"发送邮件": "sendMail",
"查看邮件": "listMail",
"登录百度网盘": "baiduCloud",
"新建日程": "createCal",
}
for key, userAction in integral_data.items():
try:
url = (
"https://mail.wo.cn/coremail/s/?func=club:addClubInfo&sid="
+ str(sid)
)
data_json = {
"uid": str(phone),
"userAction": "" + str(userAction),
"userType": "integral",
}
response = requests.post(
url=url, headers=headers, data=json.dumps(data_json)
)
code = json.loads(response.text).get("code")
msg.append({"name": key, "value": "app积分结果:" + str(code)})
except Exception as e:
msg.append({"name": key, "value": f"app沃邮箱执行任务错误:{e}"})
# 增加成长值
growth_data = {
"每日登录": "login",
"发送邮件": "sendMail",
"查看邮件": "listMail",
"登录百度网盘": "baiduCloud",
"新建日程": "createCal",
}
for key, userAction in growth_data.items():
try:
url = (
"https://mail.wo.cn/coremail/s/?func=club:addClubInfo&sid="
+ str(sid)
)
data_json = {
"uid": str(phone),
"userAction": str(userAction),
"userType": "growth",
}
response = requests.post(
url=url, headers=headers, data=json.dumps(data_json)
)
code = response.json().get("code")
msg.append({"name": key, "value": "app成长值结果:" + str(code)})
except Exception as e:
msg.append({"name": key, "value": f"app沃邮箱执行任务错误:{e}"})
# 网页
cookies = (
cookie
+ "CoremailReferer=https%3A%2F%2Fmail.wo.cn%2Fcoremail%2Fhxphone%2F;"
)
headers = {
"User-Agent": self.user_agent,
"Cookie": cookies,
"Accept": "text/x-json",
"Content-Type": "text/x-json",
"Origin": "https://mail.wo.cn",
"X-Requested-With": "com.tencent.mm",
"Sec-Fetch-Site": "same-origin",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Dest": "empty",
}
# 增加积分
integral_data = {
"每日登录": "login",
"发送邮件": "sendMail",
"查看邮件": "listMail",
"登录百度网盘": "baiduCloud",
"新建日程": "createCal",
"上传文件到中转站": "uploadFile",
}
for key, userAction in dict.items(integral_data):
try:
url = (
"https://mail.wo.cn/coremail/s/?func=club:addClubInfo&sid="
+ str(sid)
)
data_json = {
"uid": str(phone),
"userAction": str(userAction),
"userType": "integral",
}
response = requests.post(
url=url, headers=headers, data=json.dumps(data_json)
)
code = response.json().get("code")
msg.append({"name": key, "value": "网页端积分结果:" + str(code)})
except Exception as e:
msg.append({"name": key, "value": "网页端沃邮箱执行任务错误:" + str(e)})
# 增加成长值
growth_data = {
"每日登录": "login",
"发送邮件": "sendMail",
"查看邮件": "listMail",
"登录百度网盘": "baiduCloud",
"新建日程": "createCal",
"上传文件到中转站": "uploadFile",
}
for key, userAction in growth_data.items():
try:
url = (
"https://mail.wo.cn/coremail/s/?func=club:addClubInfo&sid="
+ str(sid)
)
data_json = {
"uid": str(phone),
"userAction": str(userAction),
"userType": "growth",
}
response = requests.post(
url=url, headers=headers, data=json.dumps(data_json)
)
code = response.json().get("code")
msg.append({"name": key, "value": "网页端成长值结果:" + str(code)})
except Exception as e:
msg.append({"name": key, "value": f"网页端沃邮箱执行任务错误:{e}"})
# 电脑
cookies = (
cookie
+ "domain=;CoremailReferer=https%3A%2F%2Fmail.wo.cn%2Fcoremail%2Findex.jsp%3Fcus%3D1;"
)
headers = {
"User-Agent": self.user_agent,
"Cookie": cookies,
"Accept": "text/x-json",
"Content-Type": "text/x-json",
"Origin": "https://mail.wo.cn",
"X-Requested-With": "XMLHttpRequest",
"Sec-Fetch-Site": "same-origin",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Dest": "empty",
}
# 增加积分
integral_data = {
"每日登录": "login",
"发送邮件": "sendMail",
"查看邮件": "listMail",
"登录百度网盘": "baiduCloud",
"新建日程": "createCal",
"上传文件到中转站": "uploadFile",
}
for key, userAction in integral_data.items():
try:
url = (
"https://mail.wo.cn/coremail/s/?func=club:addClubInfo&sid="
+ str(sid)
)
data_json = {"userAction": "" + str(userAction) + ""}
response = requests.post(
url=url, headers=headers, data=json.dumps(data_json)
)
code = response.json().get("code")
msg.append({"name": key, "value": "电脑端积分结果:" + str(code)})
except Exception as e:
msg.append({"name": key, "value": "电脑端沃邮箱执行任务错误:" + str(e)})
except Exception as e:
msg.append({"name": "web沃邮箱错误", "value": str(e)})
return msg
def main(self):
msg_all = ""
for check_item in self.check_items:
url = check_item.get("url")
phone = check_item.get("phone")
password = check_item.get("password")
pause21days = check_item.get("pause21days", True)
try:
cookies = self.login(womail_url=url)
if cookies:
nyan_task_msg = self.nyan_task(
cookies=cookies, pause21days=pause21days
)
club_task_msg = self.club_task(
womail_url=url, pause21days=pause21days
)
core_task_msg = self.core_task(phone=phone, password=password)
msg = nyan_task_msg + club_task_msg + core_task_msg
else:
msg = [{"name": "账号信息", "value": "登录失败"}]
except Exception as e:
msg = [{"name": "账号信息", "value": str(e)}]
msg = "\n".join([f"{one.get('name')}: {one.get('value')}" for one in msg])
msg_all += msg + "\n\n"
return msg_all
if __name__ == "__main__":
data = get_data()
_check_items = data.get("WOMAIL", [])
res = WoMail(check_items=_check_items).main()
send("联通沃邮箱", res)