1
|
|
|
# -*- coding: utf-8 -*- |
2
|
|
|
""" |
3
|
|
|
cron: 12 6 * * * |
4
|
|
|
new Env('WPS'); |
5
|
|
|
""" |
6
|
|
|
|
7
|
|
|
import json |
8
|
|
|
import random |
9
|
|
|
import sys |
10
|
|
|
import time |
11
|
|
|
|
12
|
|
|
import requests |
13
|
|
|
|
14
|
|
|
from notify_mtr import send |
15
|
|
|
from utils import get_data |
16
|
|
|
|
17
|
|
|
|
18
|
|
|
class WPS: |
19
|
|
|
def __init__(self, check_items): |
20
|
|
|
self.check_items = check_items |
21
|
|
|
self.is_sign = False |
22
|
|
|
|
23
|
|
|
# 判断 Cookie 是否失效 和 今日是否签到 |
24
|
|
|
def check(self, cookie): |
25
|
|
|
url0 = "https://vip.wps.cn/sign/mobile/v3/get_data" |
26
|
|
|
headers = { |
27
|
|
|
"Cookie": cookie, |
28
|
|
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " |
29
|
|
|
"AppleWebKit/537.36 (KHTML, like Gecko) " |
30
|
|
|
"Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586", |
31
|
|
|
} |
32
|
|
|
response = requests.get(url0, headers=headers) |
33
|
|
|
if "会员登录" in response.text: |
34
|
|
|
print("cookie 失效") |
35
|
|
|
sys.exit() |
36
|
|
|
is_sign = response.json().get("data", {}).get("is_sign") |
37
|
|
|
if is_sign: |
38
|
|
|
self.is_sign = True |
39
|
|
|
|
40
|
|
|
def sign(self, cookie): |
41
|
|
|
headers = { |
42
|
|
|
"Cookie": cookie, |
43
|
|
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " |
44
|
|
|
"AppleWebKit/537.36 (KHTML, like Gecko) " |
45
|
|
|
"Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586", |
46
|
|
|
} |
47
|
|
|
if self.is_sign: |
48
|
|
|
msg = "今日已签到" |
49
|
|
|
else: |
50
|
|
|
data0 = {"platform": "8"} # 不带验证坐标的请求 |
51
|
|
|
url = "https://vip.wps.cn/sign/v2" |
52
|
|
|
response = requests.post(url, data0, headers=headers) |
53
|
|
|
if "msg" not in response.text: |
54
|
|
|
msg = "cookie 失效" |
55
|
|
|
else: |
56
|
|
|
sus = json.loads(response.text)["result"] |
57
|
|
|
msg = f"免验证签到 --> {sus}\n" |
58
|
|
|
if sus == "error": |
59
|
|
|
yz_url = ( |
60
|
|
|
"https://vip.wps.cn/checkcode/signin/captcha.png?" |
61
|
|
|
"platform=8&encode=0&img_witdh=275.164&img_height=69.184" |
62
|
|
|
) |
63
|
|
|
data = { |
64
|
|
|
"platform": "8", |
65
|
|
|
"captcha_pos": "137.00431974731889, 36.00431593261568", |
66
|
|
|
"img_witdh": "275.164", |
67
|
|
|
"img_height": "69.184", |
68
|
|
|
} # 带验证坐标的请求 |
69
|
|
|
for n in range(10): |
70
|
|
|
requests.get(yz_url, headers=headers) |
71
|
|
|
response = requests.post(url, data, headers=headers) |
72
|
|
|
sus = json.loads(response.text)["result"] |
73
|
|
|
msg += f"{str(n + 1)} 尝试验证签到 --> {sus}\n" |
74
|
|
|
time.sleep(random.randint(0, 5) / 10) |
75
|
|
|
if sus == "ok": |
76
|
|
|
break |
77
|
|
|
msg += f"最终签到结果 --> {sus}\n" |
78
|
|
|
# {"result":"ok","data":{"exp":0,"wealth":0,"weath_double":0,"count":5,"double":0,"gift_type":"space_5","gift_id":133,"url":""},"msg":""} |
79
|
|
|
return msg |
80
|
|
|
|
81
|
|
|
def main(self): |
82
|
|
|
msg_all = "" |
83
|
|
|
for check_item in self.check_items: |
84
|
|
|
cookie = check_item.get("cookie") |
85
|
|
|
self.check(cookie) |
86
|
|
|
msg = self.sign(cookie) |
87
|
|
|
msg_all += msg + "\n\n" |
88
|
|
|
return msg_all |
89
|
|
|
|
90
|
|
|
|
91
|
|
|
if __name__ == "__main__": |
92
|
|
|
_data = get_data() |
93
|
|
|
_check_items = _data.get("WPS", []) |
94
|
|
|
result = WPS(check_items=_check_items).main() |
95
|
|
|
send("WPS", result) |
96
|
|
|
|