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

ck_ecardcheck.EcardCheck.get_ua()   A

Complexity

Conditions 1

Size

Total Lines 5
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
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