1
|
|
|
# -*- coding: utf-8 -*- |
2
|
|
|
""" |
3
|
|
|
cron: 55 15 * * * |
4
|
|
|
new Env('MEIZU 社区'); |
5
|
|
|
""" |
6
|
|
|
|
7
|
|
|
import time |
8
|
|
|
|
9
|
|
|
import requests |
10
|
|
|
|
11
|
|
|
from notify_mtr import send |
12
|
|
|
from utils import get_data |
13
|
|
|
|
14
|
|
|
|
15
|
|
|
class Meizu: |
16
|
|
|
def __init__(self, check_items): |
17
|
|
|
self.check_items = check_items |
18
|
|
|
self.url = "https://bbs-act.meizu.cn/index.php" |
19
|
|
|
|
20
|
|
|
def sign(self, cookie): |
21
|
|
|
headers = { |
22
|
|
|
"authority": "bbs-act.meizu.cn", |
23
|
|
|
"pragma": "no-cache", |
24
|
|
|
"cache-control": "no-cache", |
25
|
|
|
"accept": "application/json, text/javascript, */*; q=0.01", |
26
|
|
|
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_2) " |
27
|
|
|
"AppleWebKit/537.36 (KHTML, like Gecko) " |
28
|
|
|
"Chrome/88.0.4324.182 Safari/537.36 Edg/88.0.705.74", |
29
|
|
|
"origin": "https://bbs.meizu.cn", |
30
|
|
|
"referer": "https://bbs.meizu.cn/", |
31
|
|
|
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8", |
32
|
|
|
"cookie": cookie, |
33
|
|
|
} |
34
|
|
|
params = (("mod", "signin"), ("action", "sign")) |
35
|
|
|
res = requests.get(self.url, headers=headers, params=params).json() |
36
|
|
|
return res.get("message") |
37
|
|
|
|
38
|
|
|
def draw(self, cookie, count=0): |
39
|
|
|
headers = { |
40
|
|
|
"authority": "bbs-act.meizu.cn", |
41
|
|
|
"accept": "application/json, text/javascript, */*; q=0.01", |
42
|
|
|
"x-requested-with": "XMLHttpRequest", |
43
|
|
|
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_2) " |
44
|
|
|
"AppleWebKit/537.36 (KHTML, like Gecko) " |
45
|
|
|
"Chrome/88.0.4324.182 Safari/537.36 Edg/88.0.705.74", |
46
|
|
|
"content-type": "application/x-www-form-urlencoded", |
47
|
|
|
"origin": "https://bbs-act.meizu.cn", |
48
|
|
|
"referer": "https://bbs-act.meizu.cn/2/index.html", |
49
|
|
|
"accept-language": "zh-CN,zh;q=0.9", |
50
|
|
|
"cookie": cookie, |
51
|
|
|
} |
52
|
|
|
data = {"mod": "index", "action": "draw", "id": "2"} |
53
|
|
|
award_list = [] |
54
|
|
|
if count: |
55
|
|
|
success_count = 0 |
56
|
|
|
for i in range(count): |
57
|
|
|
try: |
58
|
|
|
res = requests.post(self.url, data, headers=headers).json() |
59
|
|
|
if res["code"] == 200: |
60
|
|
|
one_msg = res.get("data", {}).get("award_name") |
61
|
|
|
award_list.append(one_msg) |
62
|
|
|
success_count += 1 |
63
|
|
|
else: |
64
|
|
|
print(res.get("code"), res.get("message")) |
65
|
|
|
one_msg = "抽奖失败" |
66
|
|
|
except Exception as e: |
67
|
|
|
one_msg = f"抽奖失败: {e}" |
68
|
|
|
print(f"第 {i + 1} 次抽奖结果: {str(one_msg)}") |
69
|
|
|
time.sleep(5) |
70
|
|
|
msg = f"成功抽奖 {success_count} 次" |
71
|
|
|
draw_msg = f"抽奖状态: {str(msg)}" |
72
|
|
|
draw_msg += f"\n抽奖结果: {';'.join(award_list)}" |
73
|
|
|
else: |
74
|
|
|
draw_msg = "抽奖结果: 未开启抽奖" |
75
|
|
|
data = {"mod": "index", "action": "get_user_count", "id": "2"} |
76
|
|
|
user_info = requests.post(self.url, data, headers=headers).json() |
77
|
|
|
uid = user_info.get("data", {}).get("uid") |
78
|
|
|
return draw_msg, uid |
79
|
|
|
|
80
|
|
|
def main(self): |
81
|
|
|
msg_all = "" |
82
|
|
|
for check_item in self.check_items: |
83
|
|
|
cookie = check_item.get("cookie") |
84
|
|
|
try: |
85
|
|
|
draw_count = int(check_item.get("draw_count", 0)) |
86
|
|
|
except Exception as e: |
87
|
|
|
print("初始化抽奖次数失败: 重置为 0 ", e) |
88
|
|
|
draw_count = 0 |
89
|
|
|
sign_msg = self.sign(cookie) |
90
|
|
|
draw_msg, uid = self.draw(cookie, draw_count) |
91
|
|
|
msg = f"帐号信息: {uid}\n签到信息: {sign_msg}\n{draw_msg}" |
92
|
|
|
msg_all += msg + "\n\n" |
93
|
|
|
return msg_all |
94
|
|
|
|
95
|
|
|
|
96
|
|
|
if __name__ == "__main__": |
97
|
|
|
_data = get_data() |
98
|
|
|
_check_items = _data.get("MEIZU", []) |
99
|
|
|
result = Meizu(check_items=_check_items).main() |
100
|
|
|
send("MEIZU 社区", result) |
101
|
|
|
|