-
Notifications
You must be signed in to change notification settings - Fork 353
/
ck_smzdm.py
93 lines (83 loc) · 3.35 KB
/
ck_smzdm.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
# -*- coding: utf-8 -*-
"""
cron: 51 9 * * *
new Env('什么值得买');
"""
from urllib.parse import quote, unquote
import requests
from notify_mtr import send
from utils import get_data
class Smzdm:
def __init__(self, check_items):
self.check_items = check_items
@staticmethod
def sign(session):
try:
current = session.get(
url="https://zhiyou.smzdm.com/user/info/jsonp_get_current"
).json()
if current["checkin"]["has_checkin"]:
msg = (
f"用户信息: {current.get('nickname', '')}\n"
f"目前积分: {current.get('point', '')}\n"
f"经验值: {current.get('exp', '')}\n"
f"金币: {current.get('gold', '')}\n"
f"碎银子: {current.get('silver', '')}\n"
f"威望: {current.get('prestige', '')}\n"
f"等级: {current.get('level', '')}\n"
f"已经签到: {current.get('checkin', {}).get('daily_checkin_num', '')} 天"
)
else:
data = (
session.get(
url="https://zhiyou.smzdm.com/user/checkin/jsonp_checkin"
)
.json()
.get("data", {})
)
msg = (
f"用户信息: {current.get('nickname', '')}\n"
f"目前积分: {data.get('point', '')}\n"
f"增加积分: {data.get('add_point', '')}\n"
f"经验值: {data.get('exp', '')}\n"
f"金币: {data.get('gold', '')}\n"
f"威望: {data.get('prestige', '')}\n"
f"等级: {data.get('rank', '')}\n"
f"已经签到: {data.get('checkin_num', {})} 天"
)
except Exception as e:
msg = f"签到状态: 签到失败\n错误信息: {e},请重新获取 cookie"
return msg
def main(self):
msg_all = ""
for check_item in self.check_items:
cookie = {
item.split("=")[0]: quote(unquote(item.split("=")[1]))
for item in check_item.get("cookie").split("; ")
if item.split("=")[0] == "sess"
}
session = requests.session()
session.cookies.update(cookie)
session.headers.update(
{
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-CN,zh;q=0.9",
"Connection": "keep-alive",
"Host": "zhiyou.smzdm.com",
"Referer": "https://www.smzdm.com/",
"Sec-Fetch-Dest": "script",
"Sec-Fetch-Mode": "no-cors",
"Sec-Fetch-Site": "same-site",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36",
}
)
msg = self.sign(session)
msg_all += msg + "\n\n"
return msg_all
if __name__ == "__main__":
_data = get_data()
_check_items = _data.get("SMZDM", [])
result = Smzdm(check_items=_check_items).main()
send("什么值得买", result)