| Total Complexity | 7 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | # -*- coding: utf-8 -*- |
||
| 2 | """ |
||
| 3 | cron: 0 0 0 * * * |
||
| 4 | new Env('HiFiNi'); |
||
| 5 | """ |
||
| 6 | |||
| 7 | import requests |
||
| 8 | |||
| 9 | from notify_mtr import send |
||
| 10 | from utils import get_data |
||
| 11 | |||
| 12 | |||
| 13 | class HiFiNi: |
||
| 14 | def __init__(self, check_items): |
||
| 15 | self.check_items = check_items |
||
| 16 | |||
| 17 | @staticmethod |
||
| 18 | def signin(cookies): |
||
| 19 | sign_in_url = "https://www.hifini.com/sg_sign.htm" |
||
| 20 | data = {"x-requested-with": "XMLHttpRequest"} |
||
| 21 | cookies = {"enwiki_session": f"{cookies}"} |
||
| 22 | r1 = requests.post(sign_in_url, data=data, cookies=cookies) |
||
| 23 | html_text = r1.text |
||
| 24 | is_sign = False |
||
| 25 | msg = "" |
||
| 26 | for line in html_text.splitlines(): |
||
| 27 | if line.find("今天已经签过啦") != -1: |
||
| 28 | msg = "今天已经签过啦" |
||
| 29 | is_sign = True |
||
| 30 | if not is_sign: |
||
| 31 | msg = "签到成功!" |
||
| 32 | return msg |
||
| 33 | |||
| 34 | def main(self): |
||
| 35 | msg_all = "" |
||
| 36 | for i, check_item in enumerate(self.check_items, start=1): |
||
| 37 | cookie = check_item.get("cookie") |
||
| 38 | msg = f"账号{i}\n{self.signin(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("HIFINI", []) |
||
| 46 | result = HiFiNi(check_items=_check_items).main() |
||
| 47 | send("HiFiNi", result) |
||
| 48 |