forked from simple5188/jdpro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjd_try_notify.py
83 lines (76 loc) · 3.02 KB
/
jd_try_notify.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
#Source: https://github.com/Hyper-Beast
"""
cron: 20 20 * * *
new Env('京东试用通知');
"""
import requests
import json
import time
import os
import re
import sys
import random
import string
import urllib
def load_send():
global send
cur_path = os.path.abspath(os.path.dirname(__file__))
sys.path.append(cur_path)
if os.path.exists(cur_path + "/sendNotify.py"):
try:
from sendNotify import send
except:
send=False
print("加载通知服务失败~")
else:
send=False
print("加载通知服务失败~")
load_send()
def printf(text):
print(text)
sys.stdout.flush()
def getinfo(ck):
url='https://api.m.jd.com/client.action'
headers={
'accept':'application/json, text/plain, */*',
'content-type':'application/x-www-form-urlencoded',
'origin':'https://prodev.m.jd.com',
'content-length':'249',
'accept-language':'zh-CN,zh-Hans;q=0.9',
'user-agent':'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1',
'referer':'https://prodev.m.jd.com/',
'accept-encoding':'gzip, deflate, br',
'cookie':ck
}
uuid=''.join(random.sample(['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9','a','b','c','z'], 40)).replace(" ","")
area1=random.randint(10,99)
area2=random.randint(1000,9999)
area3=random.randint(10000,99999)
area4=random.randint(1000,9999)
area=str(area1)+"_"+str(area2)+"_"+str(area3)+"_"+str(area4)
data='appid=newtry&functionId=try_MyTrials&uuid='+uuid+'&clientVersion=10.3.0&client=wh5&osVersion=13.2.3&area='+area+'&networkType=wifi&body=%7B%22page%22%3A1%2C%22selected%22%3A2%2C%22previewTime%22%3A%22%22%7D'
response=requests.post(url=url,headers=headers,data=data)
isnull=True
try:
for i in range(len(json.loads(response.text)['data']['list'])):
if(json.loads(response.text)['data']['list'][i]['text']['text']).find('试用资格将保留')!=-1:
print(json.loads(response.text)['data']['list'][i]['trialName'])
send("京东试用待领取物品通知",'账号名称:'+urllib.parse.unquote(ptpin)+'\n'+'商品名称:'+json.loads(response.text)['data']['list'][i]['trialName']+"\n"+"商品链接:https://item.jd.com/"+json.loads(response.text)['data']['list'][i]['skuId']+".html")
isnull=False
i+=1
if isnull==True:
print("\t没有待领取的试用品。\n")
except:
pass
if __name__ == '__main__':
jd_try_notify=''
try:
cks = os.environ["JD_COOKIE"].split("&")
except:
f = open("/jd/config/config.sh", "r", encoding='utf-8')
cks = re.findall(r'Cookie[0-9]*="(pt_key=.*?;pt_pin=.*?;)"', f.read())
f.close()
for ck in cks:
ptpin = re.findall(r"pt_pin=(.*?);", ck)[0]
printf("--账号:" + urllib.parse.unquote(ptpin) + "--")
getinfo(ck)