-
Notifications
You must be signed in to change notification settings - Fork 7
/
ele_gy.py
728 lines (688 loc) · 35.4 KB
/
ele_gy.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
# -*- coding:utf-8 -*-
"""
cron: 10 2 * * *
new Env('饿了么果园');
"""
import json
import os
import random
import time
import requests
from urllib.parse import quote
from datetime import datetime, date
nczlck = os.environ.get('nczlck')
with open('./ck1.txt', 'r', encoding='utf-8') as file:
ck = file.read().strip()
def tq(txt):
try:
txt = txt.replace(" ", "")
pairs = txt.split(";")[:-1]
ck_json = {}
for i in pairs:
ck_json[i.split("=")[0]] = i.split("=")[1]
return ck_json
except Exception as e:
print(f'❎Cookie解析错误: {e}')
return {}
class LYB:
def __init__(self, cki):
self.name = None
self.cki = tq(cki)
self.uid = self.cki.get("unb")
self.sid = self.cki.get("cookie2")
self.token = self.cki.get("token")
self.deviceId = self.cki.get("deviceId")
self.host = 'https://acs.m.goofish.com'
self.name1 = get_ck_usid(cki)
def xsign(self, api, data, wua, v):
url = os.environ.get('signhost')
body = {
"data": data,
"api": api,
"pageId": '',
"uid": self.uid,
'sid': self.sid,
"deviceId": '',
"utdid": '',
"wua": wua,
'ttid': '1551089129819@eleme_android_10.14.3',
"v": v
}
max_retries = 5
retries = 0
while retries < max_retries:
try:
r = requests.post(url, json=body, timeout=15)
r.raise_for_status()
return r.json()
except requests.exceptions.HTTPError as e:
print(f'❎请求签名服务器失败: {e}')
except requests.exceptions.Timeout:
print("❎签名接口请求超时")
except requests.exceptions.RequestException as e:
print(f'❎请求签名服务器错误: {e}')
retries += 1
print(f"❎重试次数: {retries}")
if retries >= max_retries:
print("❎重试次数上限,尝试使用备用通道1")
return self.xsign1(api, data, wua, v)
def xsign1(self, api, data, wua, v):
url = "http://222.222.222:2222/api/getXSign"
body = {
"data": data,
"api": api,
"pageId": '',
"uid": self.uid,
'sid': self.sid,
"deviceId": '',
"utdid": '',
"wua": wua,
'ttid': '1551089129819@eleme_android_10.14.3',
"v": v
}
max_retries = 5
retries = 0
while retries < max_retries:
try:
r = requests.post(url, json=body, timeout=15)
r.raise_for_status()
return r.json()
except requests.exceptions.HTTPError as e:
print(f'❎请求签名服务器失败: {e}')
except requests.exceptions.Timeout:
print("❎签名接口请求超时")
except requests.exceptions.RequestException as e:
print(f'❎请求签名服务器错误: {e}')
retries += 1
print(f"❎重试次数: {retries}")
if retries >= max_retries:
print("❎通道1尝试次数上限,尝试使用备用通道2")
return self.xsign2(api, data, wua, v)
def xsign2(self, api, data, wua, v):
url = "http://111.111.111.111/api/getXSign"
body = {
"data": data,
"api": api,
"pageId": '',
"uid": self.uid,
'sid': self.sid,
"deviceId": '',
"utdid": '',
"wua": wua,
'ttid': '1551089129819@eleme_android_10.14.3',
"v": v
}
max_retries = 5
retries = 0
while retries < max_retries:
try:
r = requests.post(url, json=body, timeout=15)
r.raise_for_status()
return r.json()
except requests.exceptions.HTTPError as e:
print(f'❎请求签名服务器失败: {e}')
except requests.exceptions.Timeout:
print("❎签名接口请求超时")
except requests.exceptions.RequestException as e:
print(f'❎请求签名服务器错误: {e}')
retries += 1
print(f"❎重试次数: {retries}")
if retries >= max_retries:
print("❎通道2尝试次数上限,哦豁,签名通道都不可用!")
return None
def req(self, api, data, wua='False', v="1.0"):
try:
if type(data) == dict:
data = json.dumps(data)
wua = str(wua)
sign = self.xsign(api, data, wua, v)
url = f"{self.host}/gw/{api}/{v}/"
headers = {
"x-sgext": quote(sign.get('x-sgext')),
"x-sign": quote(sign.get('x-sign')),
'x-sid': self.sid,
'x-uid': self.uid,
'x-pv': '6.3',
'x-features': '1051',
'x-mini-wua': quote(sign.get('x-mini-wua')),
'content-type': 'application/x-www-form-urlencoded;charset=UTF-8',
'x-t': sign.get('x-t'),
'x-extdata': 'openappkey%3DDEFAULT_AUTH',
'x-ttid': '1551089129819@eleme_android_10.14.3',
'x-utdid': '',
'x-appkey': '24895413',
'x-devid': '',
}
params = {"data": data}
if 'wua' in sign:
params["wua"] = sign.get('wua')
max_retries = 5
retries = 0
while retries < max_retries:
try:
res = requests.post(url, headers=headers, data=params, timeout=5)
return res
except requests.exceptions.Timeout:
print("❎接口请求超时")
except requests.exceptions.RequestException as e:
print(f"❎请求异常: {e}")
retries += 1
print(f"❎重试次数: {retries}")
if retries >= max_retries:
print("❎重试次数上限")
return None
except Exception as e:
print(f'❎请求接口失败: {e}')
return None
def login(self):
api1 = 'mtop.alsc.user.detail.query'
try:
res1 = self.req(api1, json.dumps({}), 'False', "1.0")
if res1.json()['ret'][0] == 'SUCCESS::调用成功':
self.name = res1.json()["data"]["encryptMobile"]
api = 'mtop.koubei.interaction.center.common.queryintegralproperty.v2'
data = json.dumps({"templateIds": "[\"1404\"]"})
try:
res = self.req(api, data, 'False', "1.0")
if res.json()['ret'][0] == 'SUCCESS::调用成功':
print(f'[{self.name}] ✅登录成功,乐园币----[{res.json()["data"]["data"]["1404"]["count"]}]')
return True
else:
if res.json()['ret'][0] == 'FAIL_SYS_SESSION_EXPIRED::Session过期':
print(f"[{self.name1}] ❎cookie已过期,请重新获取")
return False
else:
print(f'[{self.name1}] ❌登录失败,原因:{res.text}')
return False
except Exception as e:
print(f"[{self.name1}] ❎登录失败: {e}")
return False
else:
if res1.json()['ret'][0] == 'FAIL_SYS_SESSION_EXPIRED::Session过期':
print(f"[{self.name1}] ❎cookie已过期,请重新获取")
return False
else:
print(f'[{self.name1}] ❌登录失败,原因:{res1.text}')
return False
except Exception as e:
print(f"[{self.name1}] ❎登录失败: {e}")
return False
def yqm(self):
api = 'mtop.ele.biz.growth.task.core.querytask'
data = json.dumps({"bizScene": "ORCHARD", "missionCollectionId": "178", "accountPlan": "HAVANA_COMMON",
"locationInfos": "[\"{\\\"lng\\\":\\\"105.7647817209363\\\",\\\"lat\\\":\\\"30.59868285432458\\\"}\"]"})
try:
res = self.req(api, data, 'False', "1.0")
if res is None:
return None, None
if res.json()["ret"][0] == "SUCCESS::接口调用成功":
for y in res.json()['data']['mlist']:
if y['name'] == "果园日常人传人裂变任务-百川发奖":
actId = y['actionConfig']['ext']['actId']
shareId = y['actionConfig']['ext']['shareId']
return actId, shareId
else:
if res.json()["ret"][0] == "FAIL_SYS_SESSION_EXPIRED::Session过期":
print("❎cookie已过期,请重新获取")
return None, None
else:
print(res.text)
return None, None
except Exception:
print(f'❎请求错误')
return None, None
def share(self, actid1, shareId1):
api = 'mtop.alsc.play.component.snsshare.trigger.risk'
data = json.dumps({"bizScene": "KB_ORCHARD", "shareId": shareId1, "actId": actid1, "requestId": "1720170483152",
"longitude": "99.75325090438128", "latitude": "99.597472842782736"})
try:
res = self.req(api, data, 'False', "1.0")
if res is None:
return None
if res.json()["ret"][0] == "SUCCESS::接口调用成功":
print(f"[{self.name1}] ✅助力成功")
return True
else:
if res.json()["ret"][0] == "FAIL_SYS_SESSION_EXPIRED::Session过期":
print(f"[{self.name1}] ❎cookie已过期,请重新获取")
return False
else:
if res.json()["ret"][0] == "助力次数已用完":
print(f"[{self.name1}] ❎助力次数已用完")
return False
if res.json()["ret"][0] == "今日助力次数已用完":
print(f"[{self.name1}] ❎哦豁,莫得次数咯")
return False
if res.json()["ret"][0] == "SNS_RELATION_SELF:: 人传人关系是本人":
print(f"[{self.name1}] ❎不可给自己助力")
return False
if res.json()["ret"][0] == "SNS_RELATION_LIMIT_ERROR:: 人传人关系已达上限":
print(f"[{self.name1}] ❎助力上限\n")
return 'SX'
if res.json()["ret"][0] == " 人传人关系已达上限":
print(f"[{self.name1}] ❎助力上限\n")
return 'SX'
if res.json()["ret"][0] == "分享者已被助力成功,客态重复助力":
print(f"[{self.name1}] ❎重复助力")
return None
else:
print(f"[{self.name1}] ❎助力失败")
print(res.text)
return None
except Exception as e:
print(f'请求错误', e)
return None
def prize(self):
global res, res1
api1 = 'mtop.alsc.playgame.orchard.index.batch.query'
data1 = json.dumps({
"blockRequestList": "[{\"blockCode\":\"603040_6723057310\",\"status\":\"PUBLISH\",\"tagCallWay\":\"SYNC\",\"useRequestBlockTags\":false}]",
"source": "KB_ORCHARD", "bizCode": "main",
"locationInfos": "[{\"latitude\":\"99.597472842782736\",\"longitude\":\"99.75325090438128\",\"lat\":\"99.597472842782736\",\"lng\":\"99.75325090438128\"}]",
"extData": "{\"ORCHARD_ELE_MARK\":\"KB_ORCHARD\",\"orchardVersion\":\"20240624\"}"})
try:
res1 = self.req(api1, data1, 'False', "1.0")
if res1.json()["ret"][0] == "SUCCESS::调用成功":
for y in res1.json()['data']['data']['603040_6723057310']['blockData']['instanceAssets']['tagData']:
for o in y['result']:
if o['name'] == "50g待领取水滴":
api2 = 'mtop.alsc.play.component.property.cert.trigger'
data2 = json.dumps(
{"actId": "20200629151859103125248022", "propertyId": o['instanceId'],
"templateId": "561", "bizScene": "KB_ORCHARD"})
try:
res = self.req(api2, data2, 'False', "1.0")
if res.json()["ret"][0] == "SUCCESS::接口调用成功":
amount1 = res.json()['data']['exchangeAmount']
print(f"[{self.name}] ✅领取成功, 获得水滴--[{amount1}]g")
else:
print(f"[{self.name}] ❎领取奖励失败:{res.text}")
except Exception as e:
print(res.text)
print(f'[{self.name}] 请求错误{e}')
return None
else:
if res1.json()["ret"][0] == "FAIL_SYS_SESSION_EXPIRED::Session过期":
print(f"[{self.name1}] ❎cookie已过期,请重新获取")
else:
print(f"[{self.name}] ❎获取列表失败:", res1.json())
except Exception as e:
print(f"[{self.name}] 请求错误{e}")
return None
def signinfo(self):
api = 'mtop.koubei.interactioncenter.orchard.sign.querysigninfo'
data = json.dumps(
{"latitude": "99.597472842782736", "longitude": "99.75325090438128", "bizScene": "orchard_signin"})
try:
res = self.req(api, data, 'False', "1.0")
if res.json()["ret"][0] == "SUCCESS::调用成功":
date_time = datetime.now().strftime("%Y%m%d")
for entry in res.json().get("data", {}).get("data", {}).get("signInPrizeList", []):
if entry["date"] == date_time:
for award in entry.get("ext", {}).get("awardInfo", []):
if award.get("status") != 'HAS_RECIVE':
prizeNumId = award.get("prizeNumId")
self.sign(prizeNumId, date_time)
except Exception as e:
print(f"[{self.name}] ❎请求错误{e}")
return None
def sign(self, prizeNumId, date_time):
api = 'mtop.koubei.interactioncenter.orchard.sign.receivesigninaward'
data = json.dumps({"latitude": "99.597472842782736", "longitude": "99.75325090438128", "signInDate": date_time,
"bizScene": "orchard_signin", "extInfo": "{\"prizeNumId\":\"" + prizeNumId + "\"}"})
print(f"[{self.name}] ✅签到请求:{data}")
try:
res = self.req(api, data, 'False', "1.0")
if res.json()["ret"][0] == "SUCCESS::调用成功":
print(f"[{self.name}] ✅签到成功")
else:
if res.json()["ret"][0] == "FAIL_SYS_SESSION_EXPIRED::Session过期":
print(f"[{self.name1}] ❎cookie已过期,请重新获取")
else:
print(f"[{self.name}] ❎签到失败:{res.text}")
except Exception as e:
print(f"[{self.name}] ❎签到失败{e}")
return None
def warte(self):
amount = 0
y = None
roleId = None
dygk = 0
xygk = 0
templateId = None
templateId1 = None
Sunlightvalue = 0
api = 'mtop.alsc.playgame.orchard.index.batch.query'
data1 = json.dumps({
"blockRequestList": "[{\"blockCode\":\"603040_6723057310\",\"status\":\"PUBLISH\",\"tagCallWay\":\"SYNC\",\"useRequestBlockTags\":false}]",
"source": "KB_ORCHARD", "bizCode": "main",
"locationInfos": "[{\"latitude\":\"99.597472842782736\",\"longitude\":\"99.75325090438128\",\"lat\":\"99.597472842782736\",\"lng\":\"99.75325090438128\"}]",
"extData": "{\"ORCHARD_ELE_MARK\":\"KB_ORCHARD\",\"orchardVersion\":\"20240624\"}"})
res3 = self.req(api, data1, 'False', "1.0")
if res3.json()["ret"][0] == "SUCCESS::调用成功":
for y in res3.json()['data']['data']['603040_6723057310']['blockData']['assets']['tagData']:
for o in y['totalProps']:
if o['name'] == "水":
y = o['value']
amount = int(int(o['value']) / 10)
if o['name'] == "大阳光卡":
dygk = o['value']
templateId = o['templateId']
if o['name'] == "小阳光卡":
xygk = o['value']
templateId1 = o['templateId']
# if o['name'] == "3天浇水翻倍卡":
for tag_data in res3.json()["data"]['data']["603040_6723057310"]["blockData"]["role"]["tagData"]:
for result_data in tag_data["result"]:
for role_info in result_data["roleInfoDtoList"]:
if "roleBaseInfoDto" in role_info:
role_base_info = role_info["roleBaseInfoDto"]
if "roleId" in role_base_info:
roleId = role_base_info["roleId"]
for tag_data in res3.json()["data"]["data"]["603040_6723057310"]["blockData"]["role"]["tagData"]:
for result in tag_data["result"]:
for role_info in result["roleInfoDtoList"]:
for cc in role_info["rolePropertyInfoDtoList"]:
Sunlightvalue = cc["totalPropertyCnt"]
print(
f"✅水滴:{y}g\n✅可浇水:{amount}次\n✅阳光值: {Sunlightvalue}\n✅大阳光卡数量: {dygk}\n✅小阳光卡数量: {xygk}")
if int(Sunlightvalue) != 100:
if int(dygk) >= 1:
print(f"[{self.name}] ✅使用大阳光卡")
for i in range(int(dygk)):
api = 'mtop.alsc.playgame.orchard.roleoperate.useprop'
data = json.dumps({"roleId": roleId, "roleType": "KB_ORCHARD",
"propertyTemplateId": templateId, "bizScene": "KB_ORCHARD",
"extParams": "{\"orchardVersion\":\"20240624\",\"popWindowVersion\":\"V2\"}"})
res = self.req(api, data, 'False', "1.0")
if res.json()["ret"][0] == "SUCCESS::调用成功":
print(f"[{self.name}] ✅第[{i + 1}]次使用大阳光卡成功")
elif res.json()["ret"][0] == "FAIL_BIZ_ROLE_USING_PROP_ENOUGH::已经是满状态":
print(f"[{self.name}] ✅阳光值达到100,停止使用阳光卡")
break
else:
print(f"[{self.name}] ❎第[{i + 1}]次使用大阳光卡失败:{res.text}")
elif int(xygk) >= 1:
print(f"[{self.name}] ✅使用小阳光卡")
for i in range(int(xygk)):
api = 'mtop.alsc.playgame.orchard.roleoperate.useprop'
data = json.dumps({"roleId": roleId, "roleType": "KB_ORCHARD",
"propertyTemplateId": templateId1, "bizScene": "KB_ORCHARD",
"extParams": "{\"orchardVersion\":\"20240624\",\"popWindowVersion\":\"V2\"}"})
res = self.req(api, data, 'False', "1.0")
if res.json()["ret"][0] == "SUCCESS::调用成功":
print(f"[{self.name}] ✅第[{i + 1}]次使用小阳光卡成功")
elif res.json()["ret"][0] == "FAIL_BIZ_ROLE_USING_PROP_ENOUGH::已经是满状态":
print(f"[{self.name}] ✅阳光值达到100,停止使用阳光卡")
break
else:
print(f"[{self.name}] ❎第[{i + 1}]次使用小阳光卡失败:{res.text}")
else:
print(f"[{self.name}] ❎没有阳光卡可以用咯")
else:
if res3.json()["ret"][0] == "FAIL_SYS_SESSION_EXPIRED::Session过期":
print(f"[{self.name1}] ❎cookie已过期,请重新获取")
return 0, '0', 0
else:
print(f"[{self.name}] ❎获取列表失败:", res3.json())
return 0, '0', 0
return amount, roleId, Sunlightvalue
def water(self):
total_progress = 0
total_watering = 0
amount1, roleId1, Sunlightvalue = self.warte()
if roleId1 == '0':
return None
if not (int(Sunlightvalue) > 30):
print(f"[{self.name}] ❎阳光值小于30,停止浇水")
return None
for i1 in range(amount1):
api = 'mtop.alsc.playgame.orchard.roleoperate.useprop'
data2 = json.dumps({
"propertyTemplateId": "462",
"roleId": roleId1,
"latitude": "99.597472842782736",
"longitude": "99.75325090438128",
"roleType": "KB_ORCHARD",
"actId": "20200629151859103125248022",
"collectionId": "20210812150109893985929183",
"bizScene": "KB_ORCHARD",
"extParams": "{\"orchardVersion\":\"20240624\",\"popWindowVersion\":\"V2\"}"
})
res2 = self.req(api, data2, 'False', "1.0")
rede = res2.json()
if rede["ret"][0] == "SUCCESS::调用成功":
total_watering += 1
if 'progress' in rede['data']['data']['extInfo']:
progress1 = float(rede['data']['data']['extInfo']['progress'])
if 'progressBySun' in rede['data']['data']['extInfo']:
progress = progress1 + float(rede['data']['data']['extInfo']['progressBySun'])
else:
progress = progress1
total_progress += progress
print(f"[{self.name}] ✅第{total_watering}次浇水成功,获得进度--[{progress}]")
if float(progress) < 0.04:
print(f"[{self.name}] ✅进度小于0.04,停止浇水")
break
if 'processRewardShow' in rede['data']['data']['roleInfoDTO']['processRewardDTO'] and 'openFlag' in \
rede['data']['data']['roleInfoDTO']['processRewardDTO']['processRewardShow']:
if rede['data']['data']['roleInfoDTO']['processRewardDTO']['processRewardShow']['openFlag']:
rewardId = rede['data']['data']['roleInfoDTO']['processRewardDTO']['processRewardShow'][
'rewardId']
self.warte11(roleId1, rewardId)
else:
progress = 1
jg = rede['data']['data']['roleInfoDTO']['roleLevelExpInfoDto']['upgradeNeedValue']
zt = rede['data']['data']['roleInfoDTO']['roleLevelExpInfoDto']['nextLevelName']
total_progress += progress
print(f"[{self.name}] ✅第{total_watering}次浇水成功,再浇水[{jg}]次可[{zt}]")
if 'processRewardShow' in rede['data']['data']['roleInfoDTO']['processRewardDTO'] and 'openFlag' in \
rede['data']['data']['roleInfoDTO']['processRewardDTO']['processRewardShow']:
if rede['data']['data']['roleInfoDTO']['processRewardDTO']['processRewardShow']['openFlag']:
rewardId = rede['data']['data']['roleInfoDTO']['processRewardDTO']['processRewardShow'][
'rewardId']
self.warte11(roleId1, rewardId)
elif rede["ret"][0] == "FAIL_BIZ_ROLE_USING_PROP_EXP_ENOUGH::道具使用达到上限,明天再来吧":
print(f"[{self.name}] ❎第{total_watering + 1}次浇水失败: 浇水上限")
break
else:
if rede["ret"][0] == "FAIL_BIZ_ILLEGAL_ARGUMENT::角色id不能为空":
print(f"[{self.name}] ❎第{total_watering + 1}次浇水失败: 没种树浇个鸡毛水")
break
else:
print(f"[{self.name}] ❎第{total_watering + 1}次浇水失败: {rede['ret'][0]}")
time.sleep(random.randint(1, 3))
print(f"浇水{total_watering}次获得进度: {total_progress}")
def warte11(self, roleId1, rewardId):
api = 'mtop.koubei.interactioncenter.orchard.processreward.receive'
data = json.dumps(
{"roleId": roleId1, "rewardId": rewardId, "longitude": "99.75325090438128",
"latitude": "99.597472842782736", "bizScene": "KB_ORCHARD", "requestId": "1721029520763"})
res = self.req(api, data, 'False', "1.0")
if res.json()["ret"][0] == "SUCCESS::调用成功":
if "rightSendDTOS" in res.json()['data']["data"]["lotteryResultDTO"]:
for item in res.json()['data']["data"]["lotteryResultDTO"]["rightSendDTOS"]:
if "materialInfo" in item and "title" in item["materialInfo"]:
title = item["materialInfo"]["title"]
print(f"[{self.name}] ✅领取浇水奖成功,获得--[{title}]")
else:
print(f"[{self.name}] ❎领取浇水奖励失败:{res.text}")
def pk(self):
def task():
api = 'mtop.ele.biz.growth.task.core.querytask'
data = json.dumps({"bizScene": "ORCHARD", "missionCollectionId": "178", "accountPlan": "HAVANA_COMMON",
"locationInfos": "[\"{\\\"lng\\\":\\\"99.754552\\\",\\\"lat\\\":\\\"99.600419\\\"}\"]"})
try:
res = self.req(api, data, 'False', "1.0")
for tag_data in res.json()["data"]["mlist"]:
for y in tag_data["missionStageDTOS"]:
if y["status"] == "RUNNING":
skip_keywords = ['去提款', '神奇', '中国移动', '蚂蚁', '实付', '参与夺宝', '点淘', '快手',
'支付宝', '公益林', '闲鱼', '淘特', '淘宝', '点击3个', '京东', 'UC极速版',
'飞猪', '天猫', '喜马拉雅', '订阅']
skip_task = False
for keyword in skip_keywords:
if keyword in tag_data["showTitle"]:
skip_task = True
break
runtime = datetime.now().hour
if not (11 <= runtime < 13 or 17 <= runtime < 19 or 21 <= runtime < 23) and tag_data[
"showTitle"] == "每日餐点领水滴":
skip_task = True
if skip_task:
continue
name = tag_data["showTitle"]
missionDefId = tag_data["missionDefId"]
if tag_data["showTitle"] == "逛饿了么用户专属淘宝优惠":
count = '3'
elif tag_data["showTitle"] == "浏览外卖品质好店":
count = '2'
elif '邀请好友助力' in tag_data["showTitle"]:
count = '6'
elif 11 <= runtime < 13 and tag_data["showTitle"] == "每日餐点领水滴":
count = '1'
elif 17 <= runtime < 19 and tag_data["showTitle"] == "每日餐点领水滴":
count = '2'
elif 21 <= runtime < 23 and tag_data["showTitle"] == "每日餐点领水滴":
count = '3'
else:
count = '1'
pageSpm = tag_data["actionConfig"]["actionValue"].get("pageSpm", "")
pageStageTime = tag_data["actionConfig"]["actionValue"].get("pageStageTime", "")
api = 'mtop.ele.biz.growth.task.event.pageview'
payload = {
"bizScene": "ORCHARD",
"accountPlan": "HAVANA_COMMON",
"collectionId": "178",
"missionId": missionDefId,
"actionCode": "PAGEVIEW",
"asac": "2A20B11WIAXCI9QYYXRIR0",
"sync": "false"
}
if pageSpm:
payload['pageFrom'] = pageSpm
if pageStageTime:
payload['viewTime'] = pageStageTime
data = json.dumps(payload)
res = self.req(api, data, 'False', "1.0")
if res.json()["ret"][0] == "SUCCESS::接口调用成功":
print(f"[{self.name}] ✅[{name}]任务完成")
which(name, missionDefId, count)
else:
print(f"[{self.name}] ❎完成任务失败: {res.json()['ret'][0]}")
except Exception as e:
print(f"发生错误: {e}")
def which(name, missionId, count):
if name != '每日餐点领水滴' and count != '6':
for i in range(1, int(count) + 1):
api = 'mtop.ele.biz.growth.task.core.receiveprize'
data = json.dumps({
"bizScene": "ORCHARD",
"accountPlan": "HAVANA_COMMON",
"missionCollectionId": "178",
"missionId": missionId,
"count": i,
"locationInfos": "[\"{\\\"lng\\\":99.75325090438128,\\\"lat\\\":99.597472842782736}\"]"
})
res = self.req(api, data, 'False', "1.0")
if res.json()["ret"][0] == "SUCCESS::接口调用成功":
print(f"[{self.name}] ✅[{name}]奖励领取成功")
else:
print(f"[{self.name}] ❎[{name}]奖励领取失败: {res.json()['ret'][0]}")
elif '邀请好友助力' in name or name == '每日餐点领水滴':
api = 'mtop.ele.biz.growth.task.core.receiveprize'
data = json.dumps({
"bizScene": "ORCHARD",
"accountPlan": "HAVANA_COMMON",
"missionCollectionId": "178",
"missionId": missionId,
"count": count,
"locationInfos": "[\"{\\\"lng\\\":99.75325090438128,\\\"lat\\\":99.597472842782736}\"]"
})
res = self.req(api, data, 'False', "1.0")
if res.json()["ret"][0] == "SUCCESS::接口调用成功":
print(f"[{self.name}] ✅[{name}]奖励领取成功")
else:
print(f"[{self.name}] ❎[{name}]奖励领取失败: {res.json()['ret'][0]}")
task()
def main(self):
try:
if self.login():
# self.signinfo()
self.prize()
self.pk()
self.water()
except Exception as e:
print(f"[{self.name1}] 请求错误{e}")
def get_ck_usid(ck1):
try:
key_value_pairs = ck1.split(";")
for pair in key_value_pairs:
key, value = pair.split("=")
if key.lower() == "userid":
return value
except Exception:
return 'y'
if __name__ == '__main__':
today = date.today()
today_str = today.strftime('%Y%m%d')
filename = f'{today_str}nc.json'
if not os.path.exists(filename):
with open(filename, 'w') as f:
json.dump({}, f)
print("今日助力json文件不存在,已创建")
else:
print("今日助力json文件已存在")
with open(filename, 'r') as file:
data = json.load(file)
if 'elmck' in os.environ:
cookie = os.environ.get('elmck')
else:
print("❎环境变量中不存在[elmck],启用本地变量模式")
cookie = ck
if cookie == "":
print("❎本地变量为空,请设置其中一个变量后再运行")
exit(-1)
cookies = cookie.split("&")
zlck_list = nczlck.split("&")
print(f"获取到 {len(zlck_list)} 个被助力账号")
dzl_num = 0
for zlck in zlck_list:
dzl_num += 1
lyb = LYB(zlck)
actid, shareId = lyb.yqm()
if actid is None or shareId is None:
print("❎获取助力id失败")
else:
print(f"======被助力账号{dzl_num}获取邀请码成功,开始助力======")
for i, ck in enumerate(cookies):
usid = get_ck_usid(ck)
zlcs = data.get(f"{usid}", 0)
if zlcs < 3:
print(f"======被助力账号{dzl_num}-开始第{i + 1}/{len(cookies)}个账号助力======")
a = LYB(ck).share(actid, shareId)
if a == 'SX':
break
elif a:
data[f"{usid}"] = zlcs + 1
with open(filename, 'w') as file:
json.dump(data, file, indent=4)
print("2s后进行下一个账号")
time.sleep(2)
continue
elif a is False:
data[f"{usid}"] = 3
with open(filename, 'w') as file:
json.dump(data, file, indent=4)
print("2s后进行下一个账号")
time.sleep(2)
continue
else:
print("2s后进行下一个账号")
time.sleep(2)
continue
else:
continue
print(f"======被助力账号{dzl_num}-领取奖励并浇水======")
lyb.main()
print(f"======被助力账号{dzl_num}-任务结束======\n\n")