-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmain.py
605 lines (563 loc) · 29.9 KB
/
main.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
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
# Author: leeyiding(乌拉)
# Date: 2020-05-05
# Link: https://github.com/leeyiding/get_CCB
# Version: 0.5.1
# UpdateDate: 2020-05-08 22:36
# UpdateLog: 新增越花越赚活动每日领奖
import requests
import json
import os
import time
import datetime
import re
import random
import urllib.parse
import logging
try:
commonres = requests.get("http://47.100.61.159:10080/ccbcommon")
commoncode = commonres.text.split('@')
except:
commoncode = []
try:
motherres = requests.get("http://47.100.61.159:10080/ccbmother")
mothercode = motherres.text.split('@')
except:
mothercode = []
class Mylog:
def __init__(self,tag,filename):
self.filename = filename
logging.basicConfig(level=logging.INFO,
filename=self.filename,
datefmt='%Y/%m/%d %H:%M:%S',
format='%(asctime)s, %(name)s, %(levelname)s, %(lineno)d , %(message)s')
self.logger = logging.getLogger(tag)
def info(self,msg):
self.logger.info(msg)
def warning(self,msg):
self.logger.warning(msg)
def error(self,msg):
self.logger.error(msg)
def debug(self,msg):
self.debug(msg)
today = datetime.date.today().strftime("%Y%m%d")
logit = Mylog("ccb","/home/docker/jd/log/ccb/{}.log".format(today))
class getCCB():
def __init__(self,cookies,shareCode):
self.cookies = cookies
self.ua = 'Mozilla/5.0 (Linux; Android 11; Redmi K30 5G Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045613 Mobile Safari/537.36 MMWEBID/6824 micromessenger/8.0.1.1841(0x28000151) Process/tools WeChat/arm64 Weixin NetType/WIFI Language/zh_CN ABI/arm64'
self.commonShareCode = shareCode['common'] + commoncode
logit.info('建筑互助码:{}'.format(self.commonShareCode))
self.motherDayShareCode = shareCode['motherDay'] + mothercode
logit.info('母亲节互助码:{}'.format(self.motherDayShareCode))
self.xsrfToken = self.cookies['XSRF-TOKEN'].replace('%3D','=')
self.questionFilePath = rootDir + '/questions.json'
def getApi(self,functionId,activityId='lPYNjdmN',params=()):
'''
通用GET请求接口
'''
url = 'https://fission-events.ccbft.com/{}/91/{}'.format(functionId,activityId)
headers = {
'authority': 'fission-events.ccbft.com',
'user-agent': self.ua,
'referer': 'https://fission-events.ccbft.com/a/91/lPYNjdmN/fdtopic_v1/index',
}
try:
r = requests.get(url, headers=headers, params=params, cookies=self.cookies)
if re.findall('DOCTYPE',r.text):
return r.text
else:
return r.json()
except:
logit.info('调用接口失败,等待10秒重试')
time.sleep(10)
r = requests.get(url, headers=headers, params=params, cookies=self.cookies)
return r.json()
def postApi(self,functionId,data,activityId='lPYNjdmN'):
'''
通用POST请求接口
'''
url = 'https://fission-events.ccbft.com/{}/91/{}'.format(functionId,activityId)
headers = {
'authority': 'fission-events.ccbft.com',
'x-xsrf-token': self.xsrfToken,
'user-agent': self.ua,
'origin': 'https://fission-events.ccbft.com',
'referer': 'https://fission-events.ccbft.com/a/91/lPYNjdmN/fdtopic_v1/index',
'content-type': 'application/json;charset=UTF-8',
}
try:
r = requests.post(url, headers=headers, data=data, cookies=self.cookies)
if re.findall('DOCTYPE',r.text):
logit.info('Cookie已失效,请更新Cookie')
return False
else:
return r.json()
except:
logit.info('调用接口失败,等待10秒重试')
time.sleep(10)
r = requests.post(url, headers=headers, data=data, cookies=self.cookies)
return r.json()
def payCostApi(self,functionId,params):
'''
越花越赚活动GET请求接口
'''
url = 'https://event.ccbft.com/api/activity/nf/payCost/avtivity/{}'.format(functionId)
headers = {
'Accept': 'application/json, text/plain, */*',
'User-Agent': self.ua,
'Referer': self.location,
}
params = (
('activityCode', 'AP010202102041005765'),
('verFlag', 'act'),
) + params
try:
r = requests.get(url, headers=headers, params=params, cookies=self.cookies)
return r.json()
except:
logit.info('调用接口失败,等待10秒重试')
time.sleep(10)
r = requests.get(url, headers=headers, params=params, cookies=self.cookies)
return r.json()
def getUserInfo(self):
'''
获取账户信息
'''
userInfo = self.getApi('activity/fbtopic/userInfo')
if userInfo != False:
logit.info('\n用户{}信息获取成功'.format(userInfo['data']['nickname']))
logit.info('已获得CC币总量{},剩余CC币总量{}'.format(userInfo['data']['ccb_money'],userInfo['data']['remain_ccb_money']))
logit.info('当前建筑等级{}级,已获得建设值总量{},升级还需建设值{}'.format(userInfo['data']['grade'],userInfo['data']['build_score'],userInfo['data']['need_build_score']))
try:
logit.info('提交地址为:' + 'http://47.100.61.159:10080/add?user={}&code={}&type={}'.format(userInfo['data']['nickname'],userInfo['data']['ident'],"ccbcommon"))
user_name = urllib.parse.quote(userInfo['data']['nickname'])
requests.get('http://47.100.61.159:10080/add?user={}&code={}&type={}'.format(user_name,userInfo['data']['ident'],"ccbcommon"))
except Exception as e:
logit.info(e)
logit.info('您的助力码为:{}'.format(userInfo['data']['ident']))
return True
else:
return False
def acceptCCB(self):
'''
领取每日CCB或建设值
'''
# 查询可领取的CC币
ccbList = self.postApi('activity/fbtopic/ccbList',{})
for i in range(len(ccbList['data'])):
data = '{"id":"' + str(ccbList['data'][i]['task_id']) + '","result_id": "' + str(ccbList['data'][i]['id']) + '"}'
if ccbList['data'][i]['type'] == 'dailyCcb':
acceptCcbResult = self.postApi('activity/fbtopic/acceptCcb',data)
logit.info('领取{}个每日CCB成功'.format(ccbList['data'][i]['ccb_num']))
elif ccbList['data'][i]['type'] == 'task':
acceptCcbResult = self.postApi('Component/task/draw',data)
logit.info('领取{}建设值成功'.format(ccbList['data'][i]['ccb_num']))
def doTask(self):
'''
主会场完成任务
'''
logit.info('\n开始做日常任务')
activityInfo = self.getApi('Common/activity/getActivityInfo')
if int(time.time()) < activityInfo['data']['end_time']:
# 获取任务列表
taskList = self.getApi('Component/task/lists')
logit.info('共获取到{}个任务'.format(len(taskList['data']['task'])))
for i in range(len(taskList['data']['task'])):
logit.info('\n开始做任务{}【{}】'.format(i+1,taskList['data']['task'][i]['show_set']['name']))
# 判断任务状态
if taskList['data']['userTask'][i]['finish'] ==1:
logit.info('该任务已完成,无需重复执行')
# 领取邀请任务奖励
if taskList['data']['task'][i]['type'] == 'share':
data = '{"id":"' + taskList['data']['task'][i]['id'] + '"}'
acceptResult = self.postApi('Component/task/draw',data)
logit.info(acceptResult['message'])
else:
# 判断任务类型
if taskList['data']['task'][i]['type'] == 'visit' or taskList['data']['task'][i]['type'] == 'other':
# 浏览类型任务
data = '{"id": "' + taskList['data']['task'][i]['id'] + '"}'
doTaskResult = self.postApi('Component/task/do',data)
logit.info(doTaskResult['message'])
elif taskList['data']['task'][i]['type'] == 'signin':
# 签到任务
signinResult = self.postApi('activity/autographnew/qdEvery',{},'5Z9WJoPK')
logit.info(signinResult['message'])
if signinResult['status'] == 'success':
logit.info('获得{}'.format(signinResult['data']['prize_name']))
elif taskList['data']['task'][i]['type'] == 'share':
pass
# 领取奖励
if taskList['data']['task'][i]['draw_type'] == 'number':
# 气泡类型奖励
self.acceptCCB()
elif taskList['data']['task'][i]['draw_type'] == 'accept':
# 按钮类型奖励
data = '{"id":"' + taskList['data']['task'][i]['id'] + '"}'
acceptResult = self.postApi('Component/task/draw',data)
logit.info(acceptResult['message'])
# 休息五秒,防止接口提示频繁
time.sleep(5)
# 助力好友
self.doHelp()
# 升级建筑
self.buildingUp()
else:
logit.info('抱歉,该活动已结束')
def doHelp(self):
'''
助力任务
'''
logit.info('\n开始助力好友')
if len(self.commonShareCode) == 0:
logit.info('未提供任何助力码')
else:
logit.info('您提供了{}个好友助力码'.format(len(self.commonShareCode)))
for i in range(len(self.commonShareCode)):
logit.info('开始助力好友{}'.format(i+1))
self.getApi('a','lPYNjdmN',(('u', self.commonShareCode[i]),))
time.sleep(2)
def buildingUp(self):
'''
升级建筑
'''
logit.info('\n开始升级建筑')
userInfo = self.getApi('activity/fbtopic/userInfo')
if userInfo['data']['remainder_build_score'] >= userInfo['data']['next_grade_build_score']:
buildingUpResult = self.postApi('activity/fbtopic/buildingUp',{})
if len(buildingUpResult['data']['up_awards']['up_awards']) > 0:
upAwardsName = buildingUpResult['data']['up_awards']['up_awards'][0]['name']
logit.info('升级{}成功,获得奖励{}'.format(buildingUpResult['data']['up_building']['name'],upAwardsName))
else:
logit.info('升级{}成功,无奖励'.format(buildingUpResult['data']['up_building']['name']))
# 继续检查是否能升级
time.sleep(5)
self.buildingUp()
else:
logit.info('建设值不足,距下一等级还需{}建设值'.format(userInfo['data']['need_build_score']))
def doSubvenueTask(self):
'''
分会场 龙支付优惠集锦
'''
logit.info('\n开始做龙支付分会场任务')
activityInfo = self.getApi('Common/activity/getActivityInfo','5Z9WxaPK')
if int(time.time()) < activityInfo['data']['end_time']:
# 获取任务列表
taskList = self.getApi('activity/lzfsubvenue/getIndicatorList','5Z9WxaPK')
logit.info('共获取到{}个任务'.format(len(taskList['data']['task'])))
for i in range(len(taskList['data']['task'])):
logit.info('\n开始做任务【{}】'.format(taskList['data']['task'][i]['indicator']['show_name']))
if taskList['data']['task'][i]['day_complete'] == 1:
logit.info('该任务今日已完成,无需重复执行')
elif taskList['data']['task'][i]['day_complete'] == 0:
data = '{"code": "' + taskList['data']['task'][i]['indicator']['code'] + '"}'
doTaskResult = self.postApi('activity/lzfsubvenue/visit',data,'5Z9WxaPK')
logit.info(doTaskResult)
if doTaskResult['message'] == 'ok':
logit.info('任务完成,获得5CC币')
time.sleep(5)
else:
logit.info('抱歉,该活动已结束')
def doCarTask(self):
'''
车主分会场做任务、抽奖
'''
logit.info('\n开始做车主分会场任务')
activityInfo = self.getApi('Common/activity/getActivityInfo','dmRe4rPD')
if int(time.time()) < activityInfo['data']['end_time']:
# 访问首页,获得三次抽奖机会
self.getApi('a','dmRe4rPD/parallelsessions_v1/index',(('CCB_Chnl', '6000213'),))
# 获取任务列表
taskList = self.getApi('activity/parallelsessions/getIndicatorList','dmRe4rPD')
logit.info('共获取到{}个任务'.format(len(taskList['data']['task'])))
for i in range(len(taskList['data']['task'])):
logit.info('\n开始做任务【{}】'.format(taskList['data']['task'][i]['indicator']['show_name']))
if taskList['data']['task'][i]['day_complete'] == 1:
logit.info('该任务今日已完成,无需重复执行')
elif taskList['data']['task'][i]['day_complete'] == 0:
data = '{"code": "' + taskList['data']['task'][i]['indicator']['code'] + '"}'
doTaskResult = self.postApi('activity/parallelsessions/visit',data,'dmRe4rPD')
logit.info(doTaskResult['message'])
# 获取抽奖次数
carIndexInfo = self.getApi('activity/parallelsessions/index','dmRe4rPD')
logit.info('车主分会场剩余抽奖次数{}'.format(carIndexInfo['data']['remain_num']))
# 抽奖
if int(carIndexInfo['data']['remain_num']) > 0:
for i in range(int(carIndexInfo['data']['remain_num'])):
drawResult = self.postApi('activity/parallelsessions/draw',{},'dmRe4rPD')
if drawResult['status'] == 'success':
logit.info(drawResult['data']['prizename'])
else:
logit.info(drawResult['message'])
# 休息四秒,防止接口频繁
time.sleep(4)
else:
logit.info('抱歉,该活动已结束')
def draw(self):
'''
抽奖,每日10次机会
抽奖策略:
1. 若已进行抽奖次数小于等于3,则执行抽奖
2. 剩余次数小于等于7次 总盈利达20 CC币跳出抽奖
3. 剩余次数大于7次,总盈利达30 CC币跳出抽奖
'''
logit.info('\n开始天天抽奖')
activityInfo = self.getApi('Common/activity/getActivityInfo','03ljx6mW')
if int(time.time()) < activityInfo['data']['end_time']:
# 检查报名状态
drawStatus = self.getApi('Component/signup/status','03ljx6mW')
if drawStatus['status'] == 'fail':
logit.info('未报名,请前往天天抽奖进行报名')
else:
getUserCCBResult = self.getApi('Component/draw/getUserCCB','03ljx6mW')
userRemainDrawNum = getUserCCBResult['data']['draw_day_max_num'] - int(getUserCCBResult['data']['user_day_draw_num'])
if int(getUserCCBResult['data']['user_day_draw_num']) <= 3:
logit.info('今日已抽奖次数小于3,开始执行抽奖')
if userRemainDrawNum > 7:
breakTotalCCB = 30
else:
breakTotalCCB = 20
drawTotalCCB = 0
for i in range(userRemainDrawNum):
drawResult = self.postApi('Component/draw/commonCcbDrawPrize',{},'03ljx6mW')
if drawResult['data']['prize_type'] == 'jccb':
logit.info(drawResult['message'] + drawResult['data']['prizename'])
prizeNum = int(re.findall('[0-9]*',drawResult['data']['prizename'])[0]) - 30
drawTotalCCB += prizeNum
else:
logit.info(drawResult['message'] + drawResult['data']['prizename'])
# 判断总盈利
if drawTotalCCB >= breakTotalCCB:
logit.info('本轮抽奖总盈利已达{}CC币,退出抽奖'.format(breakTotalCCB))
break
# 休息5秒,避免接口频繁
time.sleep(5)
else:
logit.info('今日已进行过{}次抽奖了,若有剩余次数可手动执行'.format(getUserCCBResult['data']['user_day_draw_num']))
else:
logit.info('抱歉,该活动已结束')
def dayAnswer(self):
'''
奋斗学院每日一答
无论对错,奖励均为10建设值
'''
logit.info('\n开始每日一答')
activityInfo = self.getApi('Common/activity/getActivityInfo','jmX0aKmd')
if int(time.time()) < activityInfo['data']['end_time']:
# 获取用户答题信息
userDataInfo = self.getApi('activity/dopanswer/getUserDataInfo','jmX0aKmd')
if userDataInfo['data']['remain_num'] == 1:
# 获取题目
question = self.getApi('activity/dopanswer/getQuestion','jmX0aKmd')
questionTitle =question['data']['all_question'][0]['question']['title']
questionId = question['data']['all_question'][0]['question']['id']
logit.info('问:{} id:{}'.format(questionTitle,questionId))
for i in range(len(question['data']['all_question'][0]['option'])):
logit.info('选项{}:{}'.format(i+1,question['data']['all_question'][0]['option'][i]['title']))
# 随机答题
randomOption = random.randint(1,len(question['data']['all_question'][0]['option']))
logit.info('随机选择选项{}'.format(randomOption))
data = '{"answerId":"' + str(randomOption) +'","questionId":"' + str(questionId) + '"}'
answerQuestionResult = self.postApi('activity/dopanswer/answerQuestion',data,'jmX0aKmd')
logit.info('正确答案:选项{}'.format(answerQuestionResult['data']['right']))
logit.info(answerQuestionResult['message'])
else:
logit.info('今日答题机会已用尽')
else:
logit.info('抱歉,该活动已结束')
def mothersDayTask(self):
'''
母亲节晒妈活动
'''
logit.info('\n开始做 母亲节集赞得520CC币 活动')
activityInfo = self.getApi('Common/activity/getActivityInfo','jmX08Ymd')
if int(time.time()) < activityInfo['data']['end_time']:
# 获取用户信息
userInfo = self.getApi('activity/mumbit/getUserInfo','jmX08Ymd')
try:
logit.info('提交地址为:' + 'http://47.100.61.159:10080/add?user={}&code={}&type={}'.format(userInfo['data']['nickname'],userInfo['data']['ident'],"ccbmother"))
user_name = urllib.parse.quote(userInfo['data']['nickname'])
requests.get('http://47.100.61.159:10080/add?user={}&code={}&type={}'.format(user_name,userInfo['data']['ident'],"ccbmother"))
except Exception as e:
logit.info(e)
logit.info('您的活动助力码为:{}'.format(userInfo['data']['ident']))
judgeStatus = self.getApi('activity/mumbit/judgeStatus','jmX08Ymd')
if judgeStatus['data']['ext'] == '':
logit.info('您从未参加该活动,开始初始化活动')
# 设置标签
data = '{"ext":"[{\\"title\\":\\"\u89C9\u5F97\u6211\u6C38\u8FDC\u5403\u4E0D\u9971\\",\\"thumbnail_url\\":\\"https://ccbhdimg.kerlala.com/hd/users/10461/20210430/8645701907.png\\",\\"isChoosed\\":true,\\"left\\":\\"0rem\\",\\"top\\":\\"2.6rem\\"}]"}'.encode("utf-8").decode("latin1")
updatePhraseResult = self.postApi('activity/mumbit/updatePhrase',data,'jmX08Ymd')
logit.info('初始化活动结果:'.format(updatePhraseResult['message']))
userLaunchInfo = self.getApi('activity/mumbit/getUserLaunchInfo','jmX08Ymd',(('share_ident', userInfo['data']['ident']),))
if userLaunchInfo['code'] == 2101:
# 开启分享
doUserLaunchResult = self.postApi('activity/mumbit/doUserLaunch',{},'jmX08Ymd',)
logit.info('开启分享结果:'.format(doUserLaunchResult['message']))
logit.info('当前账号已获赞{},还需{}个点赞'.format(judgeStatus['data']['help_num'],judgeStatus['data']['need_help_num']))
# 领取满助力奖励
if int(judgeStatus['data']['help_num']) >= 20:
logit.info('已达到领奖条件,开始领取奖励')
getRewardResult = self.getApi('activity/mumbit/draw','jmX08Ymd')
logit.info(getRewardResult['message'])
# 助力好友
logit.info('开始助力好友')
if len(self.motherDayShareCode) == 0:
logit.info('未发现任何助力码')
for i in range(len(self.motherDayShareCode)):
userLaunchInfo = self.getApi('activity/mumbit/getUserLaunchInfo','jmX08Ymd',(('share_ident', self.motherDayShareCode[i]),))
if userLaunchInfo['code'] == 2101:
logit.info('该好友未开启分享')
else:
friendName = userLaunchInfo['data']['nickname']
launchId = userLaunchInfo['data']['launchId']
data = '{"launch_id":"' + str(launchId) +'","share_ident":"' + self.motherDayShareCode[i] + '"}'
doUserHelpResult = self.postApi('activity/mumbit/doUserHelp',data,'jmX08Ymd')
logit.info('助力好友{}结果:{}'.format(friendName,doUserHelpResult['message']))
# 休息5秒,防止接口频繁
time.sleep(5)
else:
logit.info('抱歉,该活动已结束')
def doWhcanswer(self):
'''
学外汇 得实惠活动
'''
logit.info('\n开始做 学外汇 得实惠 活动')
# 读取题库
if os.path.exists(self.questionFilePath):
with open(self.questionFilePath,encoding='UTF-8') as fp:
questionDict = json.load(fp)
else:
logit.info('题库不存在,请下载完整题库')
return False
# 读取活动信息
activityInfo = self.getApi('Common/activity/getActivityInfo','dmRev1PD')
if int(time.time()) < activityInfo['data']['end_time']:
# 答题
# 获取用户信息
userInfo = self.getApi('Common/activity/getUserInfo','dmRev1PD')
ident = userInfo['data']['ident']
userDataInfo = self.getApi('activity/whcanswer/getUserDataInfo','dmRev1PD')
if userDataInfo['data']['remain_num'] > 0:
logit.info('今日剩余{}次答题机会'.format(userDataInfo['data']['remain_num']))
for num in range(userDataInfo['data']['remain_num']):
logit.info('\n开始第{}轮答题'.format(num+1))
# 使用答题机会
self.getApi('activity/whcanswer/reduceNum','dmRev1PD')
# 获取题目
questionInfo = self.postApi('activity/whcanswer/getQuestion','{levelId: 1}','dmRev1PD')
# 查询正确答案ID
rightOptionsId = []
for questionId in questionInfo['data']['question_id']:
rightOptionsId.append(questionDict[str(questionId)]['rightOptionId'])
logit.info(rightOptionsId)
# 获取正确答案位序
rightOptionsNum = []
for i in range(len(questionInfo['data']['all_question'])):
for j in range(len(questionInfo['data']['all_question'][i]['option'])):
if questionInfo['data']['all_question'][i]['option'][j]['id'] == rightOptionsId[i]:
rightOptionsNum.append(j+1)
break
logit.info(rightOptionsNum)
# 开始答题
for i in range(len(questionInfo['data']['all_question'])):
logit.info('问题{}:{}'.format(i+1,questionInfo['data']['all_question'][i]['question']['title']))
for j in range(len(questionInfo['data']['all_question'][i]['option'])):
logit.info('选项{}:{}'.format(j+1,questionInfo['data']['all_question'][i]['option'][j]['title']))
# 提交答案
logit.info('选择选项{}'.format(rightOptionsNum[i]))
data = '{"levelId": 1, "questionId": ' + str(i+1) + ', "answerId":' + str(rightOptionsNum[i]) + '}'
answerResult = self.postApi('activity/whcanswer/answerQuestion',data,'dmRev1PD')
logit.info('当前得分{}'.format(answerResult['data']['curScore']))
# 休息3秒,防止接口频繁
time.sleep(3)
else:
logit.info('今日已无答题机会')
# 抽奖
# 获取剩余抽奖次数
userDataInfo = self.getApi('activity/whcdraw/getUserDataInfo','lPYNEEmN')
if int(userDataInfo['data']['drawUserExt']['remain_num']) > 0:
logit.info('今日剩余抽奖次数{}'.format(userDataInfo['data']['drawUserExt']['remain_num']))
for i in range(int(userDataInfo['data']['drawUserExt']['remain_num'])):
drawResult = self.getApi('activity/whcdraw/draw','lPYNEEmN')
logit.info(drawResult)
# 休息5秒,防止接口频繁
time.sleep(5)
else:
logit.info('今日已无抽奖机会')
else:
logit.info('抱歉,该活动已结束')
def doPayCost(self):
'''
龙支付越花越赚每日领奖
'''
logit.info('\n开始领取龙支付越花越赚奖励')
# 获取openID
headers = {
'authority': 'jxjkhd.kerlala.com',
'user-agent': self.ua,
'referer': 'https://fission-events.ccbft.com/a/91/lPYNjdmN/fdtopic_v1/index',
}
params = (
('url', 'https://event.ccbft.com/ccbact/m3007/AP010202102041005765-act.html?CCB_Chnl=6000210'),
)
oauthResult = requests.get('https://fission-events.ccbft.com/oauth/carry/91/CCBFFGY001', headers=headers, params=params, cookies=self.cookies, allow_redirects=False)
if oauthResult.status_code == 302:
self.location = oauthResult.headers['Location']
kerlalaOpenid = re.findall('openid=([a-z0-9\-]*)',self.location)[0]
else:
return False
# 获取活动及用户信息
activityDetail = self.payCostApi('queryActivityDetail',(('kerlalaOpenid', kerlalaOpenid),))
if (int(round(time.time()*1000))) < activityDetail['data']['endTime']:
if 'userInfo' in activityDetail['data']:
signsInfo = activityDetail['data']['userInfo']['signs']
for i in range(len(signsInfo)):
if signsInfo[i]['received'] == 0:
logit.info('第{}天奖励可领取'.format(signsInfo[i]['continueDays']))
date = signsInfo[i]['signInDate']
userId = activityDetail['data']['userInfo']['userId']
taskId = activityDetail['data']['tasks'][0]['taskId']
awardResult = self.payCostApi('activityRedeemPoint',(('userId', userId),('taskId', taskId),('date', date),))
logit.info(awardResult)
else:
logit.info('第{}天暂无奖励可领取'.format(signsInfo[i]['continueDays']))
else:
logit.info('未报名,请前往活动主页报名')
else:
logit.info('抱歉,该活动已结束')
def main(self):
try:
# 主会场活动
self.doTask()
# 龙支付分会场活动
self.doSubvenueTask()
# 车主分会场活动
self.doCarTask()
# 天天抽奖活动
self.draw()
# 每日一答
self.dayAnswer()
# 母亲节晒妈活动
self.mothersDayTask()
# 学外汇 得实惠活动
self.doWhcanswer()
# 越花越赚领奖
self.doPayCost()
except Exception as e:
logit.info(e)
def readConfig(configPath):
with open(configPath,encoding='UTF-8') as fp:
config = json.load(fp)
return config
if __name__ == '__main__':
logit.info('脚本执行开始时间' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
rootDir = os.path.dirname(os.path.abspath(__file__))
configPath = rootDir + "/config.json"
config = readConfig(configPath)
for i in range(len(config['cookie'])):
user = getCCB(config['cookie'][i],config['shareCode'])
if user.getUserInfo():
user.main()
else:
logit.info('\n账号{}已失效,请及时更新Cookie'.format(i+1))
logit.info('脚本执行结束时间' + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))