Total Complexity | 5 |
Total Lines | 56 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | # -*- coding: utf-8 -*- |
||
2 | """ |
||
3 | cron: 1 15 * * * |
||
4 | new Env('恩山论坛'); |
||
5 | """ |
||
6 | |||
7 | import re |
||
8 | import time |
||
9 | |||
10 | import requests |
||
11 | |||
12 | from notify_mtr import send |
||
13 | from utils import get_data |
||
14 | |||
15 | |||
16 | class Enshan: |
||
17 | def __init__(self, check_items): |
||
18 | self.check_items = check_items |
||
19 | |||
20 | @staticmethod |
||
21 | def sign(cookie): |
||
22 | url = ( |
||
23 | "https://www.right.com.cn/FORUM/home.php?mod=spacecp&ac=credit&showcredit=1" |
||
24 | ) |
||
25 | headers = { |
||
26 | "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " |
||
27 | "AppleWebKit/537.36 (KHTML, like Gecko) " |
||
28 | "Chrome/92.0.4515.131 Safari/537.36", |
||
29 | "Cookie": cookie, |
||
30 | } |
||
31 | session = requests.session() |
||
32 | response = session.get(url, headers=headers) |
||
33 | try: |
||
34 | coin = re.findall("恩山币: </em>(.*?)nb ", response.text)[0] |
||
35 | point = re.findall("<em>积分: </em>(.*?)<span", response.text)[0] |
||
36 | res = f"恩山币:{coin}\n积分:{point}" |
||
37 | except Exception as e: |
||
38 | res = str(e) |
||
39 | return res |
||
40 | |||
41 | def main(self): |
||
42 | msg_all = "" |
||
43 | for i, check_item in enumerate(self.check_items, start=1): |
||
44 | cookie = str(check_item.get("cookie")) |
||
45 | msg = f"账号{i}\n------ 签到结果 ------\n{self.sign(cookie)}" |
||
46 | time.sleep(1) |
||
47 | msg_all += msg + "\n\n" |
||
48 | return msg_all |
||
49 | |||
50 | |||
51 | if __name__ == "__main__": |
||
52 | _data = get_data() |
||
53 | _check_items = _data.get("ENSHAN", []) |
||
54 | result = Enshan(check_items=_check_items).main() |
||
55 | send("恩山论坛", result) |
||
56 |