|
1
|
|
|
# -*- coding: utf-8 -*- |
|
2
|
|
|
""" |
|
3
|
|
|
cron: 51 9 * * * |
|
4
|
|
|
new Env('什么值得买APP'); |
|
5
|
|
|
""" |
|
6
|
|
|
|
|
7
|
|
|
from urllib.parse import quote, unquote |
|
8
|
|
|
|
|
9
|
|
|
import requests, json, time, hashlib |
|
10
|
|
|
|
|
11
|
|
|
from notify_mtr import send |
|
12
|
|
|
from utils import get_data |
|
13
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
class Smzdm: |
|
16
|
|
|
def __init__(self, check_items): |
|
17
|
|
|
self.check_items = check_items |
|
18
|
|
|
|
|
19
|
|
|
@staticmethod |
|
20
|
|
|
def sign(cookie): |
|
21
|
|
|
try: |
|
22
|
|
|
ts = int(round(time.time() * 1000)) |
|
23
|
|
|
url = 'https://user-api.smzdm.com/robot/token' |
|
24
|
|
|
headers = { |
|
25
|
|
|
'Host': 'user-api.smzdm.com', |
|
26
|
|
|
'Content-Type': 'application/x-www-form-urlencoded', |
|
27
|
|
|
'Cookie': f'{cookie}', |
|
28
|
|
|
'User-Agent': 'smzdm_android_V10.4.1 rv:841 (22021211RC;Android12;zh)smzdmapp', |
|
29
|
|
|
} |
|
30
|
|
|
data = { |
|
31
|
|
|
"f": "android", |
|
32
|
|
|
"v": "10.4.1", |
|
33
|
|
|
"weixin": 1, |
|
34
|
|
|
"time": ts, |
|
35
|
|
|
"sign": hashlib.md5(bytes(f'f=android&time={ts}&v=10.4.1&weixin=1&key=apr1$AwP!wRRT$gJ/q.X24poeBInlUJC', encoding='utf-8')).hexdigest().upper() |
|
36
|
|
|
} |
|
37
|
|
|
html = requests.post(url=url, headers=headers, data=data) |
|
38
|
|
|
result = html.json() |
|
39
|
|
|
token = result['data']['token'] |
|
40
|
|
|
|
|
41
|
|
|
Timestamp = int(round(time.time() * 1000)) |
|
42
|
|
|
data = { |
|
43
|
|
|
"f": "android", |
|
44
|
|
|
"v": "10.4.1", |
|
45
|
|
|
"sk": "ierkM0OZZbsuBKLoAgQ6OJneLMXBQXmzX+LXkNTuKch8Ui2jGlahuFyWIzBiDq/L", |
|
46
|
|
|
"weixin": 1, |
|
47
|
|
|
"time": Timestamp, |
|
48
|
|
|
"token": token, |
|
49
|
|
|
"sign": hashlib.md5(bytes(f'f=android&sk=ierkM0OZZbsuBKLoAgQ6OJneLMXBQXmzX+LXkNTuKch8Ui2jGlahuFyWIzBiDq/L&time={Timestamp}&token={token}&v=10.4.1&weixin=1&key=apr1$AwP!wRRT$gJ/q.X24poeBInlUJC', encoding='utf-8')).hexdigest().upper() |
|
50
|
|
|
} |
|
51
|
|
|
url = 'https://user-api.smzdm.com/checkin' |
|
52
|
|
|
url2 = 'https://user-api.smzdm.com/checkin/all_reward' |
|
53
|
|
|
headers = { |
|
54
|
|
|
'Host': 'user-api.smzdm.com', |
|
55
|
|
|
'Content-Type': 'application/x-www-form-urlencoded', |
|
56
|
|
|
'Cookie': f'{cookie}', |
|
57
|
|
|
'User-Agent': 'smzdm_android_V10.4.1 rv:841 (22021211RC;Android12;zh)smzdmapp', |
|
58
|
|
|
} |
|
59
|
|
|
html = requests.post(url=url, headers=headers, data=data) |
|
60
|
|
|
html2 = requests.post(url=url2, headers=headers, data=data) |
|
61
|
|
|
result = json.loads(html.text) |
|
62
|
|
|
result2 = json.loads(html2.text) |
|
63
|
|
|
if result2['error_code'] == '0': |
|
64
|
|
|
msg = result2["title"] + result2["sub_title"] |
|
65
|
|
|
else: |
|
66
|
|
|
msg = result['error_msg'] |
|
67
|
|
|
except Exception as e: |
|
68
|
|
|
msg = f"签到状态: 签到失败\n错误信息: {e},请重新获取 cookie" |
|
69
|
|
|
return msg |
|
70
|
|
|
|
|
71
|
|
|
def main(self): |
|
72
|
|
|
msg_all = "" |
|
73
|
|
|
|
|
74
|
|
|
for check_item in self.check_items: |
|
75
|
|
|
msg = self.sign(check_item.get("cookie")) |
|
76
|
|
|
msg_all += msg + "\n\n" |
|
77
|
|
|
return msg_all |
|
78
|
|
|
|
|
79
|
|
|
|
|
80
|
|
|
if __name__ == "__main__": |
|
81
|
|
|
_data = get_data() |
|
82
|
|
|
_check_items = _data.get("SMZDM", []) |
|
83
|
|
|
result = Smzdm(check_items=_check_items).main() |
|
84
|
|
|
send("什么值得买APP", result) |
|
85
|
|
|
|