-
Notifications
You must be signed in to change notification settings - Fork 274
/
TaskCenter.py
475 lines (443 loc) · 20.3 KB
/
TaskCenter.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
# !/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time : 2021/9/12
# @Author : MashiroF
# @File : TaskCenter.py
# @Software: PyCharm
'''
cron: 25 5,12 * * * TaskCenter.py
new Env('欢太任务中心');
'''
import os
import re
import sys
import time
import random
import requests
# 配置文件
try:
from HT_config import downFlag,notifyBlackList,logger
except Exception as error:
logger.info(f'失败原因:{error}')
sys.exit(0)
# 判断是否发生下载行为
if downFlag == True:
logger.info('发生下载行为,应退出程序,编辑配置文件')
sys.exit(0)
# 配信文件
try:
from sendNotify import send
except Exception as error:
logger.info('推送文件有误')
logger.info(f'失败原因:{error}')
sys.exit(0)
# 导入账户
try:
from HT_account import accounts
lists = accounts
except Exception as error:
logger.info(f'失败原因:{error}')
lists = []
# 配信内容格式
allMess = ''
def notify(content=None):
global allMess
allMess = allMess + content + '\n'
logger.info(content)
# 日志录入时间
notify(f"任务:欢太任务中心\n时间:{time.strftime('%Y-%m-%d %H:%M:%S',time.localtime())}")
# 欢太任务中心类
class TaskCenter:
def __init__(self,dic):
self.dic = dic
self.sess = requests.session()
# 登录验证
def login(self):
url = 'https://store.oppo.com/cn/oapi/users/web/member/check'
headers = {
'Host': 'store.oppo.com',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'Content-Type': 'application/x-www-form-urlencoded',
'Connection': 'keep-alive',
'Accept-Language': 'zh-cn',
'Accept-Encoding': 'gzip, deflate, br',
}
response = self.sess.get(url=url,headers=headers).json()
if response['code'] == 200:
notify(f"{self.dic['user']}\t登录成功")
return True
else:
notify(f"{self.dic['user']}\t登录失败")
return False
# 任务中心
# 位置:我的 -> 任务中心
# 函数作用:获取任务数据以及判断CK是否正确
def getTaskList(self):
url = 'https://store.oppo.com/cn/oapi/credits/web/credits/show'
headers = {
'Host': 'store.oppo.com',
'Connection': 'keep-alive',
'source_type': '501',
'clientPackage': 'com.oppo.store',
'Accept': 'application/json, text/plain, */*',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN,en-US;q=0.9',
'X-Requested-With': 'com.oppo.store',
'Referer': 'https://store.oppo.com/cn/app/taskCenter/index?us=gerenzhongxin&um=hudongleyuan&uc=renwuzhongxin'
}
response = self.sess.get(url=url,headers=headers).json()
if response['code'] == 200:
self.taskData = response['data']
return True
else:
notify(f"{self.dic['user']}\t失败原因:{response['errorMessage']}")
return False
# 每日签到
# 位置: APP → 我的 → 签到
def signIn(self):
signInData = self.taskData['userReportInfoForm'] # 签到数据源
if signInData['status'] == 0 :
for each in signInData['gifts']:
if each['today'] == True:
url = 'https://store.oppo.com/cn/oapi/credits/web/report/immediately'
headers = {
'Host': 'store.oppo.com',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'Content-Type': 'application/x-www-form-urlencoded',
'Connection': 'keep-alive',
'Accept-Language': 'zh-CN,en-US;q=0.9',
'Accept-Encoding': 'gzip, deflate, br',
'referer':'https://store.oppo.com/cn/app/taskCenter/index'
}
data = {
'amount': each['credits']
}
while True:
response = self.sess.post(url=url, headers=headers,data=data).json()
if response['code'] == 200:
notify(f"{self.dic['user']}\t签到结果:{response['data']['message']}")
break
elif response['code'] == 1000005:
data = {
'amount': each['credits'],
'type': each['type'],
'gift': each['gift']
}
else:
notify(f"{self.dic['user']}\t签到结果:{response['errorMessage']}")
break
elif signInData['status'] == 1:
notify(f"{self.dic['user']}\t今日已签到")
else:
notify(f"{self.dic['user']}\t未知错误")
# 秒杀详情页获取商品数据
def getGoodMess(self,count=10):
taskUrl = f'https://msec.opposhop.cn/goods/v1/SeckillRound/goods/{random.randint(100,250)}' # 随机商品
headers = {
'clientPackage': 'com.oppo.store',
'Host': 'msec.opposhop.cn',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'Content-Type': 'application/x-www-form-urlencoded',
'Connection': 'keep-alive',
'User-Agent': 'okhttp/3.12.12.200sp1',
'Accept-Encoding': 'gzip',
}
params = {
'pageSize':count + random.randint(1,3)
}
response = self.sess.get(url=taskUrl,headers=headers,params=params).json()
if response['meta']['code'] == 200:
return response
# 整合每日浏览、分享、推送数据
def dailyTask(self):
if self.taskData['everydayList'] != None:
for eachTask in self.taskData['everydayList']: # 每日任务数据源
if eachTask['marking'] == 'daily_viewgoods':
self.viewData = eachTask
elif eachTask['marking'] == 'daily_sharegoods':
self.shareData = eachTask
# elif eachTask['marking'] == 'daily_viewpush':
# self.pushData = eachTask
return True
else:
notify(f"[每日任务]\t任务数据获取失败,跳过")
return False
# 浏览任务
def runViewTask(self):
if self.viewData['completeStatus'] == 0:
self.viewGoods(count=self.viewData['times'] - self.viewData['readCount'], flag=1)
elif self.viewData['completeStatus'] == 1:
self.cashingCredits(self.viewData['name'],self.viewData['marking'], self.viewData['type'],self.viewData['credits'])
elif self.viewData['completeStatus'] == 2:
notify(f"[{self.viewData['name']}]\t已完成,奖励已领取")
time.sleep(random.randint(3,5))
# 浏览商品
def viewGoods(self, count,flag,dic=None):
headers = {
'clientPackage': 'com.oppo.store',
'Host': 'msec.opposhop.cn',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'Content-Type': 'application/x-www-form-urlencoded',
'Connection': 'keep-alive',
'User-Agent': 'okhttp/3.12.12.200sp1',
'Accept-Encoding': 'gzip'
}
result = self.getGoodMess(count=count) # 秒杀列表存在商品url
if result['meta']['code'] == 200:
for each in result['detail']:
url = f"https://msec.opposhop.cn/goods/v1/info/sku?skuId={each['skuid']}"
self.sess.get(url=url,headers=headers)
notify(f"正在浏览商品id:{each['skuid']}...")
time.sleep(random.randint(7,10))
if flag == 1: # 来源任务中心的浏览任务
self.cashingCredits(self.viewData['name'], self.viewData['marking'], self.viewData['type'],self.viewData['credits'])
elif flag == 2: # 来源赚积分的浏览任务
self.receiveAward(dic)
# 分享任务
def runShareTask(self):
if self.shareData['completeStatus'] == 0:
self.shareGoods(flag=1,count=self.shareData['times'] - self.shareData['readCount'])
elif self.shareData['completeStatus'] == 1:
self.cashingCredits(self.shareData['name'],self.shareData['marking'], self.shareData['type'],self.shareData['credits'])
elif self.shareData['completeStatus'] == 2:
notify(f"[{self.shareData['name']}]\t已完成,奖励已领取")
time.sleep(random.randint(1,3))
# 分享商品
def shareGoods(self, flag,count):
url = 'https://msec.opposhop.cn/users/vi/creditsTask/pushTask'
headers = {
'clientPackage': 'com.oppo.store',
'Host': 'msec.opposhop.cn',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'Content-Type': 'application/x-www-form-urlencoded',
'Connection': 'keep-alive',
'User-Agent': 'okhttp/3.12.12.200sp1',
'Accept-Encoding': 'gzip',
}
params = {
'marking': 'daily_sharegoods'
}
for i in range(count + random.randint(1,3)):
self.sess.get(url=url,headers=headers,params=params)
notify(f"正在执行第{i+1}次微信分享...")
time.sleep(random.randint(7,10))
if flag == 1: # 来源任务中心
self.cashingCredits(self.shareData['name'],self.shareData['marking'], self.shareData['type'],self.shareData['credits'])
# # 浏览推送任务
# def runViewPush(self):
# if self.pushData['completeStatus'] == 0:
# self.viewPush(self.pushData['times'] - self.pushData['readCount'])
# elif self.pushData['completeStatus'] == 1:
# self.cashingCredits(self.pushData['name'], self.pushData['marking'], self.pushData['type'],self.pushData['credits'])
# elif self.pushData['completeStatus'] == 2:
# notify(f"[{self.pushData['name']}]\t已完成,奖励已领取")
# time.sleep(random.randint(1,3))
# # 点击推送
# def viewPush(self,count):
# url = 'https://msec.opposhop.cn/users/vi/creditsTask/pushTask'
# headers = {
# 'clientPackage': 'com.oppo.store',
# 'Host': 'msec.opposhop.cn',
# 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
# 'Content-Type': 'application/x-www-form-urlencoded',
# 'Connection': 'keep-alive',
# 'User-Agent': 'okhttp/3.12.12.200sp1',
# 'Accept-Encoding': 'gzip',
# }
# params = {
# 'marking': 'daily_viewpush'
# }
# for i in range(count + random.randint(1,3)):
# self.sess.get(url=url,headers=headers,params=params)
# notify(f"正在点击第{i+1}次信息推送...")
# time.sleep(random.randint(7,10))
# self.cashingCredits(self.pushData['name'], self.pushData['marking'], self.pushData['type'],self.pushData['credits'])
# 领取奖励
def cashingCredits(self,name,marking,type,amount):
url = 'https://store.oppo.com/cn/oapi/credits/web/credits/cashingCredits'
headers = {
'Host': 'store.oppo.com',
'Connection': 'keep-alive',
'Origin': 'https://store.oppo.com',
'clientPackage': 'com.oppo.store',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'Content-Type': 'application/x-www-form-urlencoded',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN,en-US;q=0.9',
'Referer':'https://store.oppo.com/cn/app/taskCenter/index?us=gerenzhongxin&um=hudongleyuan&uc=renwuzhongxin'
}
data = {
'marking':marking,
'type':str(type),
'amount':str(amount)
}
response = self.sess.post(url=url,headers=headers,data=data).json()
if response['code'] == 200:
notify(f'{name}\t已领取奖励')
else:
notify(f'{name}\t领取失败')
time.sleep(random.randint(3,5))
# 赚积分(抽奖)任务
def runEarnPoint(self):
aid = 1418 # 抓包结果为固定值:1418
url = 'https://hd.oppo.com/task/list'
headers = {
'Host':'hd.oppo.com',
'Connection': 'keep-alive',
'Referer':'https://hd.oppo.com/act/m/2021/jifenzhuanpan/index.html?us=gerenzhongxin&um=hudongleyuan&uc=yingjifen',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN,en-US;q=0.9',
}
params = {
'aid':aid
}
response = self.sess.get(url=url,headers=headers,params=params).json()
if response['no'] == '200':
for each in response['data']:
if each['title'] == '每日签到':
if each['t_status'] == 0:
self.clockIn(each)
elif each['t_status'] == 1:
self.receiveAward(each)
elif each['t_status'] == 2:
notify(f"[{each['title']}]\t任务完成")
elif each['title'] == '浏览商详':
if each['t_status'] == 0:
self.viewGoods(count=6,flag=2,dic=each)
elif each['t_status'] == 1:
self.receiveAward(each)
elif each['t_status'] == 2:
notify(f"[{each['title']}]\t任务完成")
time.sleep(random.randint(3,5))
# 赚积分 -> 每日打卡
def clockIn(self,dic):
aid = 1418
url = 'https://hd.oppo.com/task/finish'
headers = {
'Host': 'hd.oppo.com',
'Connection': 'keep-alive',
'Accept': '*/*',
'Origin': 'https://hd.oppo.com',
'X-Requested-With': 'XMLHttpRequest',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Referer': 'https://hd.oppo.com/act/m/2021/2021/realmejifendalu/index.html',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN,en-US;q=0.9'
}
data = {
'aid': aid,
't_index': dic['t_index']
}
response = self.sess.post(url=url,headers=headers,data=data).json()
if response['no'] == '200':
notify(f"[{dic['title']}]\t{response['msg']}")
self.receiveAward(dic)
else:
notify(f"[{dic['title']}]\t{response['msg']}")
time.sleep(random.randint(3,5))
# 领取奖励
def receiveAward(self,dic):
aid = 1418
url = 'https://hd.oppo.com/task/award'
headers = {
'Host': 'hd.oppo.com',
'Connection': 'keep-alive',
'Accept': '*/*',
'Origin': 'https://hd.oppo.com',
'X-Requested-With': 'XMLHttpRequest',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Referer': 'https://hd.oppo.com/act/m/2021/jifenzhuanpan/index.html?us=gerenzhongxin&um=hudongleyuan&uc=yingjifen',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN,en-US;q=0.9'
}
data = {
'aid': aid,
't_index': dic['t_index']
}
response = self.sess.post(url=url,headers=headers,data=data).json()
if response['no'] == '200':
notify(f"[{dic['title']}]\t{response['msg']}")
else:
notify(f"[{dic['title']}]\t{response['msg']}")
time.sleep(random.randint(3,5))
# 跑任务中心
# 位置:我的 -> 任务中心
def runTaskCenter(self):
self.signIn() # 签到打卡
if self.dailyTask() == True:
self.runViewTask() # 浏览任务
self.runShareTask() # 分享任务
self.runEarnPoint() # 赚积分
# self.runViewPush() # 浏览推送任务(已下架)
# 获取积分数量(只找到这个,找不到昨天积分数据)
def getIntegral(self):
url = 'https://store.oppo.com/cn/oapi/credits/web/credits/show'
headers = {
'Host': 'store.oppo.com',
'Connection': 'keep-alive',
'source_type': '501',
'clientPackage': 'com.oppo.store',
'Accept': 'application/json, text/plain, */*',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN,en-US;q=0.9',
'X-Requested-With': 'com.oppo.store',
'Referer': 'https://store.oppo.com/cn/app/taskCenter/index?us=gerenzhongxin&um=hudongleyuan&uc=renwuzhongxin'
}
response = self.sess.get(url=url,headers=headers).json()
if response['code'] == 200:
return f"{self.dic['user']}\t总积分:{response['data']['userCredits']}"
else:
return f"{self.dic['user']}\t错误原因:{response}"
# 执行欢太商城实例对象
def start(self):
self.sess.headers.update({
"User-Agent":self.dic['UA']
})
self.sess.cookies.update({
"Cookie": self.dic['CK']
})
if self.login() == True:
if self.getTaskList() == True: # 获取任务中心数据,判断CK是否正确(登录可能成功,但无法跑任务)
self.runTaskCenter() # 运行任务中心
notify(self.getIntegral())
# 检测CK是否存在必备参数
def checkHT(dic):
CK = dic['CK']
if len(re.findall(r'source_type=.*?;',CK)) == 0:
notify(f"{dic['user']}\tCK格式有误:可能缺少`source_type`字段")
return False
if len(re.findall(r'TOKENSID=.*?;',CK)) == 0:
notify(f"{dic['user']}\tCK格式有误:可能缺少`TOKENSID`字段")
return False
if len(re.findall(r'app_param=.*?[;]?',CK)) == 0:
notify(f"{dic['user']}\tCK格式有误:可能缺少`app_param`字段")
return False
return True
# 兼容云函数
def main_handler(event, context):
global lists
for each in lists:
if each['CK']!='' and each['UA'] != '':
if checkHT(each):
taskCenter = TaskCenter(each)
for count in range(3):
try:
time.sleep(random.randint(2,5)) # 随机延时
taskCenter.start()
break
except requests.exceptions.ConnectionError:
notify(f"{taskCenter.dic['user']}\t请求失败,随机延迟后再次访问")
time.sleep(random.randint(2,5))
continue
else:
notify(f"账号: {taskCenter.dic['user']}\n状态: 取消登录\n原因: 多次登录失败")
break
elif not all(each.values()):
notify("账号:空账户\t状态:跳过")
else:
notify(f"账号: {each['user']}\n状态: 取消登录\n原因: json数据不齐全")
notify('*' * 40 + '\n')
if not os.path.basename(__file__).split('_')[-1][:-3] in notifyBlackList:
send('欢太任务中心',allMess)
if __name__ == '__main__':
main_handler(None,None)