ck_toolu   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 32
dl 0
loc 48
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A ToolLu.__init__() 0 2 1
A ToolLu.main() 0 7 2
A ToolLu.sign() 0 14 2
1
# -*- coding: utf-8 -*-
2
"""
3
cron: 0 6 * * *
4
new Env('在线工具');
5
"""
6
7
import re
8
9
import requests
10
11
from notify_mtr import send
12
from utils import get_data
13
14
15
class ToolLu:
16
    def __init__(self, check_items):
17
        self.check_items = check_items
18
19
    @staticmethod
20
    def sign(cookie):
21
        url = "https://id.tool.lu/sign"
22
        headers = {
23
            "cookie": cookie,
24
            "user-agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) "
25
            "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36",
26
        }
27
        response = requests.get(url, headers=headers)
28
        day = re.findall("你已经连续签到(.*),再接再厉!", response.text)
29
        if len(day) == 0:
30
            return "cookie 失效"
31
        day = day[0].replace(" ", "")
32
        return f"连续签到 {day}"
33
34
    def main(self):
35
        msg_all = ""
36
        for check_item in self.check_items:
37
            cookie = check_item.get("cookie")
38
            msg = self.sign(cookie)
39
            msg_all += msg + "\n\n"
40
        return msg_all
41
42
43
if __name__ == "__main__":
44
    _data = get_data()
45
    _check_items = _data.get("TOOLU", [])
46
    result = ToolLu(check_items=_check_items).main()
47
    send("在线工具", result)
48