Passed
Push — master ( c7076b...545fb7 )
by
unknown
02:31
created

ck_ecardcheck   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 29
dl 0
loc 45
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A EcardCheck.get_ua() 0 5 1
A EcardCheck.randomstr() 0 6 2
A EcardCheck.main() 0 8 2
1
# -*- coding: utf-8 -*-
2
"""
3
:author @limoruirui
4
cron: 18 0-23/6 * * *
5
new Env('爱企查e卡监控');
6
"""
7
8
from random import choice
9
10
import requests
11
12
from notify_mtr import send
13
from utils import get_data
14
15
16
class EcardCheck:
17
    @staticmethod
18
    def get_ua(brower_name):
19
        url = "https://ghproxy.com/https://raw.githubusercontent.com/Oreomeow/checkinpanel/master/user-agent.json"
20
        useragent = choice(requests.get(url).json()[brower_name])
21
        return useragent
22
23
    @staticmethod
24
    def randomstr(numb):
25
        s = ""
26
        for _ in range(numb):
27
            s = s + choice("abcdefghijklmnopqrstuvwxyz0123456789")
28
        return s
29
30
    def main(self):
31
        url = "https://aiqicha.baidu.com/usercenter/getBenefitStatusAjax"
32
        headers = {
33
            "User-Agent": self.get_ua("Safari"),
34
            "Referer": f"https://aiqicha.baidu.com/m/usercenter/exchangeList?VNK={self.randomstr(8)}",
35
        }
36
        if requests.get(url, headers=headers).json()["data"]["AQ03008"] == 1:
37
            send("爱企查e卡监控", "爱企查京东e卡有货,请进行兑换")
38
39
40
if __name__ == "__main__":
41
    data = get_data()
42
    ecardcheck = data.get("ECARDCHECK")
43
    if ecardcheck:
44
        EcardCheck().main()
45