forked from faintout/myself-script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sfsy.py
2144 lines (1948 loc) · 95.5 KB
/
sfsy.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
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# !/usr/bin/python3
# -- coding: utf-8 --
"""
打开小程序或APP-我的-积分, 捉以下几种url之一,把整个url放到变量 sfsyUrl 里,多账号换行分割
https://mcs-mimp-web.sf-express.com/mcs-mimp/share/weChat/shareGiftReceiveRedirect
https://mcs-mimp-web.sf-express.com/mcs-mimp/share/app/shareRedirect
每天跑一到两次就行
"""
# cron: 11 6,9,12,15,18 * * *
# const $ = new Env("顺丰速运");
import hashlib
import json
import os
import random
import time
import re
from datetime import datetime, timedelta
from sys import exit
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
os.environ['NEW_VAR'] ='sfsyUrl' #环境变量
# 禁用安全请求警告
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
IS_DEV = False
if os.path.isfile('notify.py'):
from notify import send
print("加载通知服务成功!")
else:
print("加载通知服务失败!")
send_msg = ''
one_msg = ''
def Log(cont=''):
global send_msg, one_msg
print(cont)
if cont:
one_msg += f'{cont}\n'
send_msg += f'{cont}\n'
# 1905 #0945 #6332 #6615 2559
inviteId = ['DC00EBE47C4A4FB0BC63E255AC746987','52B41115D3934EF3828810C5674EEB9C','5DBE609F545745509966630D6C3CA691']
class RUN:
def __init__(self, info, index):
global one_msg
one_msg = ''
split_info = info.split('@')
url = split_info[0]
len_split_info = len(split_info)
last_info = split_info[len_split_info - 1]
self.send_UID = None
if len_split_info > 0 and "UID_" in last_info:
self.send_UID = last_info
self.index = index + 1
Log(f"\n---------开始执行第{self.index}个账号>>>>>")
self.s = requests.session()
self.s.verify = False
self.s.mount('https://', requests.adapters.HTTPAdapter(
max_retries=requests.adapters.Retry(
total=3,
backoff_factor=0.5,
status_forcelist=[500, 502, 503, 504]
)
))
self.headers = {
'Host': 'mcs-mimp-web.sf-express.com',
'upgrade-insecure-requests': '1',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36 NetType/WIFI MicroMessenger/7.0.20.1781(0x6700143B) WindowsWechat(0x63090551) XWEB/6945 Flue',
'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'sec-fetch-site': 'none',
'sec-fetch-mode': 'navigate',
'sec-fetch-user': '?1',
'sec-fetch-dest': 'document',
'accept-language': 'zh-CN,zh',
'platform': 'MINI_PROGRAM',
}
self.anniversary_black = False
self.member_day_black = False
self.member_day_red_packet_drew_today = False
self.member_day_red_packet_map = {}
self.login_res = self.login(url)
self.today = datetime.now().strftime('%Y-%m-%d')
self.answer = False
self.max_level = 8
self.packet_threshold = 1 << (self.max_level - 1)
self.max_retries = 3 # 最大重试次数
self.retry_delay = 3 # 重试间隔秒数
def get_deviceId(self, characters='abcdef0123456789'):
result = ''
for char in 'xxxxxxxx-xxxx-xxxx':
if char == 'x':
result += random.choice(characters)
elif char == 'X':
result += random.choice(characters).upper()
else:
result += char
return result
def login(self, sfurl):
try:
ress = self.s.get(sfurl, headers=self.headers, timeout=30)
# print(ress.text)
self.user_id = self.s.cookies.get_dict().get('_login_user_id_', '')
self.sessionId = self.s.cookies.get_dict().get('sessionId', '')
self.phone = self.s.cookies.get_dict().get('_login_mobile_', '')
self.mobile = self.phone[:3] + "*" * 4 + self.phone[7:] if self.phone else ''
if self.phone:
Log(f'用户:【{self.mobile}】登陆成功')
return True
else:
Log(f'获取用户信息失败')
return False
except requests.exceptions.SSLError as e:
Log(f'SSL连接错误: {str(e)}')
return False
except requests.exceptions.RequestException as e:
Log(f'请求错误: {str(e)}')
return False
except Exception as e:
Log(f'未知错误: {str(e)}')
return False
def getSign(self):
timestamp = str(int(round(time.time() * 1000)))
token = 'wwesldfs29aniversaryvdld29'
sysCode = 'MCS-MIMP-CORE'
data = f'token={token}×tamp={timestamp}&sysCode={sysCode}'
signature = hashlib.md5(data.encode()).hexdigest()
data = {
'sysCode': sysCode,
'timestamp': timestamp,
'signature': signature
}
self.headers.update(data)
return data
def do_request(self, url, data={}, req_type='post'):
self.getSign()
for retry in range(self.max_retries):
try:
if req_type.lower() == 'get':
response = self.s.get(url, headers=self.headers, timeout=30)
elif req_type.lower() == 'post':
response = self.s.post(url, headers=self.headers, json=data, timeout=30)
else:
raise ValueError('Invalid req_type: %s' % req_type)
# 检查响应状态码
response.raise_for_status()
res = response.json()
return res
except requests.exceptions.SSLError as e:
if retry < self.max_retries - 1:
print(f'SSL错误,{self.retry_delay}秒后进行第{retry + 2}次重试: {str(e)}')
time.sleep(self.retry_delay)
continue
else:
print(f'SSL错误,已重试{self.max_retries}次: {str(e)}')
return None
except (requests.exceptions.RequestException, json.JSONDecodeError) as e:
if retry < self.max_retries - 1:
print(f'请求失败,{self.retry_delay}秒后进行第{retry + 2}次重试: {str(e)}')
time.sleep(self.retry_delay)
continue
else:
print(f'请求失败,已重试{self.max_retries}次: {str(e)}')
return None
except Exception as e:
if retry < self.max_retries - 1:
print(f'未知错误,{self.retry_delay}秒后进行第{retry + 2}次重试: {str(e)}')
time.sleep(self.retry_delay)
continue
else:
print(f'未知错误,已重试{self.max_retries}次: {str(e)}')
return None
def sign(self):
print(f'>>>>>>开始执行签到')
json_data = {"comeFrom": "vioin", "channelFrom": "WEIXIN"}
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~integralTaskSignPlusService~automaticSignFetchPackage'
url2 ='https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~integralTaskSignPlusService~queryPointSignAwardList'
url3 ='https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~integralTaskSignPlusService~getUnFetchPointAndDiscount'
result = self.do_request(url2, data={"channelType": "1"})
result2=self.do_request(url3, data={})
response = self.do_request(url, data=json_data)
# print(response)
if response.get('success') == True:
count_day = response.get('obj', {}).get('countDay', 0)
if response.get('obj') and response['obj'].get('integralTaskSignPackageVOList'):
packet_name = response["obj"]["integralTaskSignPackageVOList"][0]["packetName"]
Log(f'>>>签到成功,获得【{packet_name}】,本周累计签到【{count_day + 1}】天')
else:
Log(f'今日已签到,本周累计签到【{count_day + 1}】天')
else:
print(f'签到失败!原因:{response.get("errorMessage")}')
def superWelfare_receiveRedPacket(self):
print(f'>>>>>>超值福利签到')
json_data = {
'channel': 'czflqdlhbxcx'
}
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberActLengthy~redPacketActivityService~superWelfare~receiveRedPacket'
response = self.do_request(url, data=json_data)
print(response)
if response.get('success') == True:
gift_list = response.get('obj', {}).get('giftList', [])
if response.get('obj', {}).get('extraGiftList', []):
gift_list.extend(response['obj']['extraGiftList'])
gift_names = ', '.join([gift['giftName'] for gift in gift_list])
receive_status = response.get('obj', {}).get('receiveStatus')
status_message = '领取成功' if receive_status == 1 else '已领取过'
Log(f'超值福利签到[{status_message}]: {gift_names}')
else:
error_message = response.get('errorMessage') or json.dumps(response) or '无返回'
print(f'超值福利签到失败: {error_message}')
def get_SignTaskList(self, END=False):
if not END: print(f'>>>开始获取签到任务列表')
json_data = {
'channelType': '3',
'deviceId': self.get_deviceId(),
}
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~integralTaskStrategyService~queryPointTaskAndSignFromES'
response = self.do_request(url, data=json_data)
# print(response)
if response.get('success') == True and response.get('obj') != []:
totalPoint = response["obj"]["totalPoint"]
if END:
Log(f'当前积分:【{totalPoint}】')
return
Log(f'执行前积分:【{totalPoint}】')
for task in response["obj"]["taskTitleLevels"]:
self.taskId = task["taskId"]
self.taskCode = task["taskCode"]
self.strategyId = task["strategyId"]
self.title = task["title"]
status = task["status"]
skip_title = ['用行业模板寄件下单', '去新增一个收件偏好', '参与积分活动']
if status == 3:
print(f'>{self.title}-已完成')
continue
if self.title in skip_title:
print(f'>{self.title}-跳过')
continue
if self.title =='领任意生活特权福利':
json_data = {
"memGrade": 2,
"categoryCode": "SHTQ",
"showCode": "SHTQWNTJ"
}
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberGoods~mallGoodsLifeService~list'
response = self.do_request(url, data=json_data)
# print(response)
if response.get('success') == True:
goodsList = response["obj"][0]["goodsList"]
for goods in goodsList:
exchangeTimesLimit = goods['exchangeTimesLimit']
if exchangeTimesLimit >= 1:
self.goodsNo = goods['goodsNo']
print(f'领取生活权益:当前选择券号:{self.goodsNo}')
self.get_coupom()
break
else:
print(f'>领券失败!原因:{response.get("errorMessage")}')
else:
# print("taskId:", taskId)
# print("taskCode:", taskCode)
# print("----------------------")
self.doTask()
time.sleep(3)
self.receiveTask()
def doTask(self):
print(f'>>>开始去完成【{self.title}】任务')
json_data = {
'taskCode': self.taskCode,
}
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonRoutePost/memberEs/taskRecord/finishTask'
response = self.do_request(url, data=json_data)
if response.get('success') == True:
print(f'>【{self.title}】任务-已完成')
else:
print(f'>【{self.title}】任务-{response.get("errorMessage")} 1{response}')
def receiveTask(self):
print(f'>>>开始领取【{self.title}】任务奖励')
json_data = {
"strategyId": self.strategyId,
"taskId": self.taskId,
"taskCode": self.taskCode,
"deviceId": self.get_deviceId()
}
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~integralTaskStrategyService~fetchIntegral'
response = self.do_request(url, data=json_data)
if response.get('success') == True:
print(f'>【{self.title}】任务奖励领取成功!')
else:
print(f'>【{self.title}】任务-{response.get("errorMessage")}')
def do_honeyTask(self):
# 做任务
json_data = {"taskCode": self.taskCode}
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberEs~taskRecord~finishTask'
response = self.do_request(url, data=json_data)
if response.get('success') == True:
print(f'>【{self.taskType}】任务-已完成')
else:
print(f'>【{self.taskType}】任务-{response.get("errorMessage")}')
def receive_honeyTask(self):
print('>>>执行收取丰蜜任务')
# 收取
self.headers['syscode'] = 'MCS-MIMP-CORE'
self.headers['channel'] = 'wxwdsj'
self.headers['accept'] = 'application/json, text/plain, */*'
self.headers['content-type'] = 'application/json;charset=UTF-8'
self.headers['platform'] = 'MINI_PROGRAM'
json_data = {"taskType": self.taskType}
# print(json_data)
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~receiveExchangeIndexService~receiveHoney'
response = self.do_request(url, data=json_data)
if response.get('success') == True:
print(f'收取任务【{self.taskType}】成功!')
else:
print(f'收取任务【{self.taskType}】失败!原因:{response.get("errorMessage")}')
def get_coupom(self):
print('>>>执行领取生活权益领券任务')
# 领取生活权益领券
# https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberGoods~pointMallService~createOrder
json_data = {
"from": "Point_Mall",
"orderSource": "POINT_MALL_EXCHANGE",
"goodsNo": self.goodsNo,
"quantity": 1,
"taskCode": self.taskCode
}
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberGoods~pointMallService~createOrder'
response = self.do_request(url, data=json_data)
if response.get('success') == True:
print(f'>领券成功!')
else:
print(f'>领券失败!原因:{response.get("errorMessage")}')
def get_coupom_list(self):
print('>>>获取生活权益券列表')
# 领取生活权益领券
# https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberGoods~pointMallService~createOrder
json_data = {
"memGrade": 1,
"categoryCode": "SHTQ",
"showCode": "SHTQWNTJ"
}
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberGoods~mallGoodsLifeService~list'
response = self.do_request(url, data=json_data)
# print(response)
if response.get('success') == True:
goodsList = response["obj"][0]["goodsList"]
for goods in goodsList:
exchangeTimesLimit = goods['exchangeTimesLimit']
if exchangeTimesLimit >= 1:
self.goodsNo = goods['goodsNo']
print(f'当前选择券号:{self.goodsNo}')
self.get_coupom()
break
else:
print(f'>领券失败!原因:{response.get("errorMessage")}')
def get_honeyTaskListStart(self):
print('>>>开始获取采蜜换大礼任务列表')
# 任务列表
json_data = {}
self.headers['channel'] = 'wxwdsj'
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~receiveExchangeIndexService~taskDetail'
response = self.do_request(url, data=json_data)
# print(response)
if response.get('success') == True:
for item in response["obj"]["list"]:
self.taskType = item["taskType"]
status = item["status"]
if status == 3:
print(f'>【{self.taskType}】-已完成')
if self.taskType == 'BEES_GAME_TASK_TYPE':
self.bee_need_help = False
continue
if "taskCode" in item:
self.taskCode = item["taskCode"]
if self.taskType == 'DAILY_VIP_TASK_TYPE':
self.get_coupom_list()
else:
self.do_honeyTask()
if self.taskType == 'BEES_GAME_TASK_TYPE':
self.honey_damaoxian()
time.sleep(2)
def honey_damaoxian(self):
print('>>>执行大冒险任务')
# 大冒险
gameNum = 5
for i in range(1, gameNum):
json_data = {
'gatherHoney': 20,
}
if gameNum < 0: break
print(f'>>开始第{i}次大冒险')
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~receiveExchangeGameService~gameReport'
response = self.do_request(url, data=json_data)
# print(response)
stu = response.get('success')
if stu:
gameNum = response.get('obj')['gameNum']
print(f'>大冒险成功!剩余次数【{gameNum}】')
time.sleep(2)
gameNum -= 1
elif response.get("errorMessage") == '容量不足':
print(f'> 需要扩容')
self.honey_expand()
else:
print(f'>大冒险失败!【{response.get("errorMessage")}】')
break
def honey_expand(self):
print('>>>容器扩容')
# 大冒险
gameNum = 5
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~receiveExchangeIndexService~expand'
response = self.do_request(url, data={})
# print(response)
stu = response.get('success', False)
if stu:
obj = response.get('obj')
print(f'>成功扩容【{obj}】容量')
else:
print(f'>扩容失败!【{response.get("errorMessage")}】')
def honey_indexData(self, END=False):
if not END: print('\n>>>>>>>开始执行采蜜换大礼任务')
# 邀请
random_invite = random.choice([invite for invite in inviteId if invite != self.user_id])
self.headers['channel'] = 'wxwdsj'
json_data = {"inviteUserId": random_invite}
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~receiveExchangeIndexService~indexData'
response = self.do_request(url, data=json_data)
if response.get('success') == True:
usableHoney = response.get('obj').get('usableHoney')
if END:
Log(f'当前丰蜜:【{usableHoney}】')
return
Log(f'执行前丰蜜:【{usableHoney}】')
taskDetail = response.get('obj').get('taskDetail')
activityEndTime = response.get('obj').get('activityEndTime', '')
activity_end_time = datetime.strptime(activityEndTime, "%Y-%m-%d %H:%M:%S")
current_time = datetime.now()
if current_time.date() == activity_end_time.date():
Log("本期活动今日结束,请及时兑换")
else:
print(f'本期活动结束时间【{activityEndTime}】')
if taskDetail != []:
for task in taskDetail:
self.taskType = task['type']
self.receive_honeyTask()
time.sleep(2)
def EAR_END_2023_TaskList(self):
print('\n>>>>>>开始年终集卡任务')
# 任务列表
json_data = {
"activityCode": "YEAR_END_2023",
"channelType": "MINI_PROGRAM"
}
self.headers['channel'] = 'xcx23nz'
self.headers['platform'] = 'MINI_PROGRAM'
self.headers['syscode'] = 'MCS-MIMP-CORE'
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~activityTaskService~taskList'
response = self.do_request(url, data=json_data)
# print(response)
if response.get('success') == True:
for item in response["obj"]:
self.title = item["taskName"]
self.taskType = item["taskType"]
status = item["status"]
if status == 3:
print(f'>【{self.taskType}】-已完成')
continue
if self.taskType == 'INTEGRAL_EXCHANGE':
self.EAR_END_2023_ExchangeCard()
elif self.taskType == 'CLICK_MY_SETTING':
self.taskCode = item["taskCode"]
self.addDeliverPrefer()
if "taskCode" in item:
self.taskCode = item["taskCode"]
self.doTask()
time.sleep(3)
self.EAR_END_2023_receiveTask()
else:
print(f'暂时不支持【{self.title}】任务')
# if self.taskType == 'BEES_GAME_TASK_TYPE':
# self.honey_damaoxian()
self.EAR_END_2023_getAward()
self.EAR_END_2023_GuessIdiom()
def addDeliverPrefer(self):
print(f'>>>开始【{self.title}】任务')
json_data = {
"country": "中国",
"countryCode": "A000086000",
"province": "北京市",
"provinceCode": "A110000000",
"city": "北京市",
"cityCode": "A111000000",
"county": "东城区",
"countyCode": "A110101000",
"address": "1号楼1单元101",
"latitude": "",
"longitude": "",
"memberId": "",
"locationCode": "010",
"zoneCode": "CN",
"postCode": "",
"takeWay": "7",
"callBeforeDelivery": 'false',
"deliverTag": "2,3,4,1",
"deliverTagContent": "",
"startDeliverTime": "",
"selectCollection": 'false',
"serviceName": "",
"serviceCode": "",
"serviceType": "",
"serviceAddress": "",
"serviceDistance": "",
"serviceTime": "",
"serviceTelephone": "",
"channelCode": "RW11111",
"taskId": self.taskId,
"extJson": "{\"noDeliverDetail\":[]}"
}
url = 'https://ucmp.sf-express.com/cx-wechat-member/member/deliveryPreference/addDeliverPrefer'
response = self.do_request(url, data=json_data)
if response.get('success') == True:
print('新增一个收件偏好,成功')
else:
print(f'>【{self.title}】任务-{response.get("errorMessage")}')
def EAR_END_2023_ExchangeCard(self):
print(f'>>>开始积分兑换年卡')
json_data = {
"exchangeNum": 2,
"activityCode": "YEAR_END_2023",
"channelType": "MINI_PROGRAM"
}
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonNoLoginPost/~memberNonactivity~yearEnd2023TaskService~integralExchange'
response = self.do_request(url, data=json_data)
if response.get('success') == True:
receivedAccountList = response['obj']['receivedAccountList']
for card in receivedAccountList:
print(f'>获得:【{card["urrency"]}】卡【{card["amount"]}】张!')
else:
print(f'>【{self.title}】任务-{response.get("errorMessage")}')
def EAR_END_2023_getAward(self):
print(f'>>>开始抽卡')
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~yearEnd2023GardenPartyService~getAward'
for l in range(10):
for i in range(0, 3):
json_data = {
"cardType": i
}
response = self.do_request(url, data=json_data)
# print(response)
if response.get('success') == True:
receivedAccountList = response['obj']['receivedAccountList']
for card in receivedAccountList:
print(f'>获得:【{card["currency"]}】卡【{card["amount"]}】张!')
elif response.get('errorMessage') == '达到限流阈值,请稍后重试':
break
elif response.get('errorMessage') == '用户信息失效,请退出重新进入':
break
else:
print(f'>抽卡失败:{response.get("errorMessage")}')
time.sleep(3)
def EAR_END_2023_GuessIdiom(self):
print(f'>>>开始猜成语')
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~yearEnd2023GuessIdiomService~win'
for i in range(1, 11):
json_data = {
"index": i
}
response = self.do_request(url, data=json_data)
if response.get('success') == True:
print(f'第{i}关成功!')
# receivedAccountList = response['obj']['receivedAccountList']
# for card in receivedAccountList:
# print(f'>获得:【{card["urrency"]}】卡【{card["amount"]}】张!')
else:
print(f'第{i}关失败!')
def EAR_END_2023_receiveTask(self):
print(f'>>>开始领取【{self.title}】任务奖励')
json_data = {
"taskType": self.taskType,
"activityCode": "YEAR_END_2023",
"channelType": "MINI_PROGRAM"
}
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonNoLoginPost/~memberNonactivity~yearEnd2023TaskService~fetchMixTaskReward'
response = self.do_request(url, data=json_data)
if response.get('success') == True:
print(f'>【{self.title}】任务奖励领取成功!')
else:
print(f'>【{self.title}】任务-{response.get("errorMessage")}')
def anniversary2024_weekly_gift_status(self):
print(f'\n>>>>>>>开始周年庆任务')
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~anniversary2024IndexService~weeklyGiftStatus'
response = self.do_request(url)
if response.get('success') == True:
weekly_gift_list = response.get('obj', {}).get('weeklyGiftList', [])
for weekly_gift in weekly_gift_list:
if not weekly_gift.get('received'):
receive_start_time = datetime.strptime(weekly_gift['receiveStartTime'], '%Y-%m-%d %H:%M:%S')
receive_end_time = datetime.strptime(weekly_gift['receiveEndTime'], '%Y-%m-%d %H:%M:%S')
current_time = datetime.now()
# print(current_time)
# print(receive_start_time)
# print(receive_end_time)
if receive_start_time <= current_time <= receive_end_time:
self.anniversary2024_receive_weekly_gift()
else:
error_message = response.get('errorMessage') or json.dumps(response) or '无返回'
print(f'查询每周领券失败: {error_message}')
if '系统繁忙' in error_message or '用户手机号校验未通过' in error_message:
self.anniversary_black = True
def anniversary2024_receive_weekly_gift(self):
print(f'>>>开始领取每周领券')
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~anniversary2024IndexService~receiveWeeklyGift'
response = self.do_request(url)
if response.get('success'):
product_names = [product['productName'] for product in response.get('obj', [])]
print(f'每周领券: {product_names}')
else:
error_message = response.get('errorMessage') or json.dumps(response) or '无返回'
print(f'每周领券失败: {error_message}')
if '系统繁忙' in error_message or '用户手机号校验未通过' in error_message:
self.anniversary_black = True
def anniversary2024_taskList(self):
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~activityTaskService~taskList'
data = {
'activityCode': 'ANNIVERSARY_2024',
'channelType': 'MINI_PROGRAM'
}
response = self.do_request(url, data)
if response and response.get('success'):
tasks = response.get('obj', [])
# 过滤出状态为1的任务并尝试接收奖励
for task in filter(lambda x: x['status'] == 1, tasks):
if self.anniversary_black:
return
for _ in range(task['canReceiveTokenNum']):
self.anniversary2024_fetchMixTaskReward(task)
# 过滤出状态为2的任务并完成任务
for task in filter(lambda x: x['status'] == 2, tasks):
if self.anniversary_black:
return
if task['taskType'] in ['PLAY_ACTIVITY_GAME', 'PLAY_HAPPY_ELIMINATION', 'PARTAKE_SUBJECT_GAME']:
pass
elif task['taskType'] == 'FOLLOW_SFZHUNONG_VEDIO_ID':
pass
elif task['taskType'] in ['BROWSE_VIP_CENTER', 'GUESS_GAME_TIP', 'CREATE_SFID', 'CLICK_MY_SETTING',
'CLICK_TEMPLATE', 'REAL_NAME', 'SEND_SUCCESS_RECALL', 'OPEN_SVIP',
'OPEN_FAST_CARD', 'FIRST_CHARGE_NEW_EXPRESS_CARD', 'CHARGE_NEW_EXPRESS_CARD',
'INTEGRAL_EXCHANGE']:
pass
else:
for _ in range(task['restFinishTime']):
if self.anniversary_black:
break
self.anniversary2024_finishTask(task)
def anniversary2024_finishTask(self, task):
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonRoutePost/memberEs/taskRecord/finishTask'
data = {'taskCode': task['taskCode']}
response = self.do_request(url, data)
if response and response.get('success'):
print('完成任务[%s]成功' % task['taskName'])
# 完成任务后获取任务奖励的逻辑
self.anniversary2024_fetchMixTaskReward(task)
else:
print('完成任务[%s]失败: %s' % (
task['taskName'], response.get('errorMessage') or (json.dumps(response) if response else '无返回')))
def anniversary2024_fetchMixTaskReward(self, task):
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~anniversary2024TaskService~fetchMixTaskReward'
data = {
'taskType': task['taskType'],
'activityCode': 'ANNIVERSARY_2024',
'channelType': 'MINI_PROGRAM'
}
response = self.do_request(url, data)
if response and response.get('success'):
reward_info = response.get('obj', {}).get('account', {})
received_list = [f"[{item['currency']}]X{item['amount']}" for item in
reward_info.get('receivedAccountList', [])]
turned_award = reward_info.get('turnedAward', {})
if turned_award.get('productName'):
received_list.append(f"[优惠券]{turned_award['productName']}")
print('领取任务[%s]奖励: %s' % (task['taskName'], ', '.join(received_list)))
else:
error_message = response.get('errorMessage') or json.dumps(response) or '无返回'
print('领取任务[%s]奖励失败: %s' % (task['taskName'], error_message))
if '用户手机号校验未通过' in error_message:
self.anniversary_black = True
def anniversary2024_unbox(self):
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~anniversary2024CardService~unbox'
response = self.do_request(url, {})
if response and response.get('success'):
account_info = response.get('obj', {}).get('account', {})
unbox_list = [f"[{item['currency']}]X{item['amount']}" for item in
account_info.get('receivedAccountList', [])]
print('拆盒子: %s' % ', '.join(unbox_list) or '空气')
else:
error_message = response.get('errorMessage') or json.dumps(response) or '无返回'
print('拆盒子失败: %s' % error_message)
if '用户手机号校验未通过' in error_message:
self.anniversary_black = True
def anniversary2024_game_list(self):
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~anniversary2024GameParkService~list'
response = self.do_request(url, {})
try:
if response['success']:
topic_pk_info = response['obj'].get('topicPKInfo', {})
search_word_info = response['obj'].get('searchWordInfo', {})
happy_elimination_info = response['obj'].get('happyEliminationInfo', {})
if not topic_pk_info.get('isPassFlag'):
print('开始话题PK赛')
# 这里调用话题PK赛列表相关函数
self.anniversary2024_TopicPk_topicList()
if not search_word_info.get('isPassFlag') or not search_word_info.get('isFinishDailyFlag'):
print('开始找字游戏')
for i in range(1, 11):
wait_time = random.randint(1000, 3000) / 1000.0 # 转换为秒
time.sleep(wait_time)
if not self.anniversary2024_SearchWord_win(i):
break
if not happy_elimination_info.get('isPassFlag') or not happy_elimination_info.get('isFinishDailyFlag'):
print('开始消消乐')
for i in range(1, 31):
wait_time = random.randint(2000, 4000) / 1000.0 # 转换为秒
time.sleep(wait_time)
if not self.anniversary2024_HappyElimination_win(i):
break
else:
error_message = response['errorMessage'] or json.dumps(response) or '无返回'
print('查询游戏状态失败: ' + error_message)
if '用户手机号校验未通过' in error_message:
self.anniversary_black = True
except Exception as e:
print(str(e))
def anniversary2024_SearchWord_win(self, index):
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~anniversary2024SearchWordService~win'
success = True
try:
data = {'index': index}
response = self.do_request(url, data)
if response and response.get('success'):
currency_list = response.get('obj', {}).get('currencyDTOList', [])
rewards = ', '.join([f"[{c.get('currency')}]X{c.get('amount')}" for c in currency_list])
print(f'找字游戏第{index}关通关成功: {rewards if rewards else "未获得奖励"}')
else:
error_message = response.get('errorMessage') or json.dumps(response) or '无返回'
print(f'找字游戏第{index}关失败: {error_message}')
if '系统繁忙' in error_message:
success = False
except Exception as e:
print(e)
finally:
return success
def anniversary2024_HappyElimination_win(self, index):
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~anniversary2024HappyEliminationService~win'
success = True
data = {'index': index}
response = self.do_request(url, data)
try:
if response and response.get('success'):
is_award = response['obj'].get('isAward')
currency_dto_list = response['obj'].get('currencyDTOList', [])
rewards = ', '.join([f"[{c.get('currency')}]X{c.get('amount')}" for c in currency_dto_list])
print(f'第{index}关通关: {rewards if rewards else "未获得奖励"}')
else:
error_message = response.get('errorMessage') or json.dumps(response) or '无返回'
print(f'第{index}关失败: {error_message}')
if '系统繁忙' in error_message:
success = False
except Exception as e:
print(e)
success = False
finally:
return success
def anniversary2024_TopicPk_chooseSide(self, index):
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~anniversary2024TopicPkService~chooseSide'
success = True
data = {'index': index, 'choose': 0} # 选择某一边
response = self.do_request(url, data)
try:
if response and response.get('success'):
currency_dto_list = response['obj'].get('currencyDTOList', [])
rewards = ', '.join([f"[{c.get('currency')}]X{c.get('amount')}" for c in currency_dto_list])
print(f'话题PK赛选择话题{index}成功: {rewards if rewards else "未获得奖励"}')
else:
error_message = response['errorMessage'] or json.dumps(response) or '无返回'
print(f'话题PK赛选择话题{index}失败: {error_message}')
if '系统繁忙' in error_message:
success = False
except Exception as e:
print(e)
success = False
finally:
return success
def anniversary2024_TopicPk_topicList(self):
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~anniversary2024TopicPkService~topicList'
response = self.do_request(url, {})
try:
if response and response.get('success'):
topics = response['obj'].get('topics', [])
for topic in topics:
if not topic.get('choose'):
index = topic.get('index', 1)
wait_time = random.randint(2000, 4000) / 1000.0 # 转换为秒
time.sleep(wait_time) # 等待
if not self.anniversary2024_TopicPk_chooseSide(index):
break
else:
error_message = response['errorMessage'] or json.dumps(response) or '无返回'
print(f'查询话题PK赛记录失败: {error_message}')
except Exception as e:
print(e)
def anniversary2024_queryAccountStatus_refresh(self):
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~anniversary2024CardService~queryAccountStatus'
response = self.do_request(url, {})
try:
if not response or not response.get('success'):
error_message = response['errorMessage'] or json.dumps(response) or '无返回'
print(f'查询账户状态失败: {error_message}')
except Exception as e:
print(e)
def anniversary2024_TopicPk_chooseSide(self, index):
success = True
data = {
'index': index,
'choose': 0
}
self.headers['channel'] = '31annizyw'
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~anniversary2024TopicPkService~chooseSide'
result = self.do_request(url, data, 'post')
if result and result.get('success'):
currency_dto_list = result.get('obj', {}).get('currencyDTOList', [])
if currency_dto_list:
rewards = [f"[{currency['currency']}]{currency['amount']}次" for currency in currency_dto_list]
print(f'话题PK赛第{index}个话题选择成功: {", ".join(rewards)}')
else:
print(f'话题PK赛第{index}个话题选择成功')
else:
error_message = result.get('errorMessage') if result else '无返回'
print(f'话题PK赛第{index}个话题失败: {error_message}')
if error_message and '系统繁忙' in error_message:
success = False
return success
def anniversary2024_titleList(self):
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~anniversary2024GuessService~titleList'
response = self.do_request(url)
if response and response.get('success'):
guess_title_info_list = response.get('obj', {}).get('guessTitleInfoList', [])
today_titles = [title for title in guess_title_info_list if title['gameDate'] == self.today]
for title_info in today_titles:
if title_info['answerStatus']:
print('今日已回答过竞猜')
else:
answer = self.answer
if answer:
self.anniversary2024_answer(title_info, answer)
print(f'进行了答题: {answer}')
else:
error_message = response.get('errorMessage') if response else '无返回'
print(f'查询每日口令竞猜失败: {error_message}')
def anniversary2024_titleList_award(self):
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~anniversary2024GuessService~titleList'
response = self.do_request(url)
if response and response.get('success'):
guess_title_info_list = response.get('obj', {}).get('guessTitleInfoList', [])
today_awards = [title for title in guess_title_info_list if title['gameDate'] == self.today]
for award_info in today_awards:
if award_info['answerStatus']:
awards = award_info.get('awardList', []) + award_info.get('puzzleList', [])
awards_description = ', '.join([f"{award['productName']}" for award in awards])
print(f'口令竞猜奖励: {awards_description}' if awards_description else '今日无奖励')
else:
print('今日还没回答竞猜')
else:
error_message = response.get('errorMessage') if response else '无返回'
print(f'查询每日口令竞猜奖励失败: {error_message}')
# 向API发送答题请求
def anniversary2024_answer(self, answer_info):
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~anniversary2024GuessService~answer'
data = {'period': answer_info['period'], 'answerInfo': answer_info}
response = self.do_request(url, data)
if response and response.get('success'):
print('口令竞猜回答成功')
self.anniversary2024_titleList_award() # 通过奖励接口验证答案
else:
error_message = response.get('errorMessage') if response else '无返回'
print(f'口令竞猜回答失败: {error_message}')
# 查询账户状态
def anniversary2024_queryAccountStatus(self):
url = 'https://mcs-mimp-web.sf-express.com/mcs-mimp/commonPost/~memberNonactivity~anniversary2024CardService~queryAccountStatus'
result = self.do_request(url)
if result.get('success'):
account_currency_list = result.get('obj', {}).get('accountCurrencyList', [])
unbox_chance_currency = [currency for currency in account_currency_list if
currency.get('currency') == 'UNBOX_CHANCE']
unbox_chance_balance = unbox_chance_currency[0].get('balance') if unbox_chance_currency else 0
# print('可以拆' + str(unbox_chance_balance) + '次盒子')
# while unbox_chance_balance > 0:
# self.anniversary2024_unbox()
# unbox_chance_balance -= 1
else:
error_message = result.get('errorMessage') or json.dumps(result) or '无返回'
print('查询已收集拼图失败: ' + error_message)
result = self.do_request(url)
if result.get('success'):
account_currency_list = result.get('obj', {}).get('accountCurrencyList', [])
account_currency_list = [currency for currency in account_currency_list if
currency.get('currency') != 'UNBOX_CHANCE']
if account_currency_list:
cards_li = account_currency_list
card_info = []
self.cards = {
'CARD_1': 0,
'CARD_2': 0,
'CARD_3': 0,
'CARD_4': 0,
'CARD_5': 0,
'CARD_6': 0,
'CARD_7': 0,
'CARD_8': 0,
'CARD_9': 0,
'COMMON_CARD': 0
}
for card in cards_li:
currency_key = card.get('currency')
if currency_key in self.cards:
self.cards[currency_key] = int(card.get('balance'))
card_info.append('[' + card.get('currency') + ']X' + str(card.get('balance')))