-
Notifications
You must be signed in to change notification settings - Fork 1
/
constant.py
117 lines (105 loc) · 5.04 KB
/
constant.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import os
USERS = eval(os.environ['USERS'])
SERVER_KEY = os.environ['SERVER_KEY']
# LOGIN_API = 'https://app.bupt.edu.cn/uc/wap/login/check'
LOGIN_API = 'https://auth.bupt.edu.cn/authserver/login'
# LOGIN_API = 'https://app.bupt.edu.cn/ncov/wap/default/index'
GET_API = 'https://app.bupt.edu.cn/ncov/wap/default/index'
REPORT_API = 'https://app.bupt.edu.cn/ncov/wap/default/save'
# 当今日没有填报时,在https://app.bupt.edu.cn/ncov/wap/default/index下进行填报,
# 全部填完,不要提交,f12打开控制台,在Console页面下输入代码 console.log(vm.info) 就会得到以下信息,之后每天就默认填以下信息
INFO = r"""{
"address":"北京市海淀区北太平庄街道北京邮电大学计算机学院北京邮电大学海淀校区",
"area":"北京市 海淀区",
"bztcyy":"",
"city":"北京市",
"csmjry":"0",
"fjqszgjdq":"",
"geo_api_info":"{\"type\":\"complete\",\"position\":{\"Q\":39.960390625,\"R\":116.356397569445,\"lng\":116.356398,\"lat\":39.960391},\"location_type\":\"html5\",\"message\":\"Get ipLocation failed.Get geolocation success.Convert Success.Get address success.\",\"accuracy\":23,\"isConverted\":true,\"status\":1,\"addressComponent\":{\"citycode\":\"010\",\"adcode\":\"110108\",\"businessAreas\":[{\"name\":\"北下关\",\"id\":\"110108\",\"location\":{\"Q\":39.955976,\"R\":116.33873,\"lng\":116.33873,\"lat\":39.955976}},{\"name\":\"西直门\",\"id\":\"110102\",\"location\":{\"Q\":39.942856,\"R\":116.34666099999998,\"lng\":116.346661,\"lat\":39.942856}},{\"name\":\"小西天\",\"id\":\"110108\",\"location\":{\"Q\":39.957147,\"R\":116.364058,\"lng\":116.364058,\"lat\":39.957147}}],\"neighborhoodType\":\"科教文化服务;学校;高等院校\",\"neighborhood\":\"北京邮电大学\",\"building\":\"北京邮电大学计算机学院\",\"buildingType\":\"科教文化服务;学校;高等院校\",\"street\":\"西土城路\",\"streetNumber\":\"10号\",\"country\":\"中国\",\"province\":\"北京市\",\"city\":\"\",\"district\":\"海淀区\",\"township\":\"北太平庄街道\"},\"formattedAddress\":\"北京市海淀区北太平庄街道北京邮电大学计算机学院北京邮电大学海淀校区\",\"roads\":[],\"crosses\":[],\"pois\":[],\"info\":\"SUCCESS\"}",
"glksrq":"",
"gllx":"",
"gtjzzchdfh":"",
"gtjzzfjsj":"",
"ismoved":"0",
"jcbhlx":"",
"jcbhrq":"",
"jchbryfs":"",
"jcjgqr":"0",
"jcwhryfs":"",
"jhfjhbcc":"",
"jhfjjtgj":"",
"jhfjrq":"",
"mjry":"0",
"province":"北京市",
"qksm":"",
"remark":"",
"sfcxtz":"0",
"sfcxzysx":"0",
"sfcyglq":"0",
"sfjcbh":"0",
"sfjchbry":"0",
"sfjcwhry":"0",
"sfjzdezxgym":"1",
"sfjzxgym":"1",
"sfsfbh":"0",
"sftjhb":"0",
"sftjwh":"0",
"sfxk":"0",
"sfygtjzzfj":"",
"sfyyjc":"0",
"sfzx":1,
"szcs":"",
"szgj":"",
"szsqsfybl":"0",
"tw":"2",
"xjzd":"",
"xkqq":"",
"xwxgymjzqk":"3",
"ymjzxgqk":"已接种",
"zgfxdq":"0"
}"""
REASONABLE_LENGTH = 24
TIMEOUT_SECOND = 25
class HEADERS:
# REFERER_LOGIN_API = 'https://app.bupt.edu.cn/uc/wap/login'
REFERER_LOGIN_API = 'https://auth.bupt.edu.cn/authserver/login'
REFERER_POST_API = 'https://app.bupt.edu.cn/ncov/wap/default/index'
ORIGIN_BUPTAPP = 'https://app.bupt.edu.cn'
UA = ('Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) '
'Mobile/15E148 MicroMessenger/7.0.11(0x17000b21) NetType/4G Language/zh_CN')
ACCEPT_JSON = 'application/json'
ACCEPT_HTML = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'
REQUEST_WITH_XHR = 'XMLHttpRequest'
ACCEPT_LANG = 'zh-cn'
CONTENT_TYPE_UTF8 = 'application/x-www-form-urlencoded; charset=UTF-8'
def __init__(self) -> None:
raise NotImplementedError
COMMON_HEADERS = {
'User-Agent': HEADERS.UA,
'Accept-Language': HEADERS.ACCEPT_LANG,
}
COMMON_POST_HEADERS = {
'Accept': HEADERS.ACCEPT_JSON,
'Origin': HEADERS.ORIGIN_BUPTAPP,
'X-Requested-With': HEADERS.REQUEST_WITH_XHR,
'Content-Type': HEADERS.CONTENT_TYPE_UTF8,
}
from typing import Optional
from abc import ABCMeta, abstractmethod
class INotifier(metaclass=ABCMeta):
@property
@abstractmethod
def PLATFORM_NAME(self) -> str:
"""
将 PLATFORM_NAME 设为类的 Class Variable,内容是通知平台的名字(用于打日志)。
如:PLATFORM_NAME = 'Telegram 机器人'
:return: 通知平台名
"""
@abstractmethod
def notify(self, *, success, msg, data,username, name) -> None:
"""
通过该平台通知用户操作成功的消息。失败时将抛出各种异常。
:param success: 表示是否成功
:param msg: 成功时表示服务器的返回值,失败时表示失败原因;None 表示没有上述内容
:return: None
"""