Browse Source

feat: COVID-19 daily report(#master)

master
OhYee 3 years ago
parent
commit
1c1f0d9672
Signed by: OhYee
GPG Key ID: 5A9E1F63ED274FBB
  1. 10
      check/README.md
  2. 75
      check/check.py
  3. 1
      check/users.txt

10
check/README.md

@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
# 疫情打卡脚本
自动在疫情防控通打卡
账号为学号
密码为服务门户密码(默认为身份证后8位)
账户和密码使用空格分割存放在`users.txt`中,一行一个用户
疫情打卡会使用前一天的数据结合当日需要修改的参数进行打卡,因此如果有部分项目需要修改,只需要有一天手动打卡即可,后续都会继续沿用前一日的数据

75
check/check.py

@ -0,0 +1,75 @@ @@ -0,0 +1,75 @@
import requests
import datetime
import re
import json
session = requests.Session()
oldKeys = [
"ismoved", "jhfjrq", "jhfjjtgj", "jhfjhbcc", "sfxk", "xkqq", "szgj", "szcs", "zgfxdq", "mjry", "csmjry", "uid", "tw", "sfcxtz", "sfyyjc", "jcjgqr", "jcjg", "sfjcbh", "sfcxzysx", "qksm", "remark", "address", "area", "province", "city", "geo_api_info", "sfzx", "sfjcwhry", "sfcyglq", "gllx",
"glksrq", "jcbhlx", "jcbhrq", "sftjwh", "sftjhb", "fxyy", "bztcyy", "fjsj", "sfjchbry", "sfjcqz", "jcqzrq", "jcwhryfs", "jchbryfs", "xjzd", "sfsfbh", "jhfjsftjwh", "jhfjsftjhb", "szsqsfybl", "sfygtjzzfj", "gtjzzfjsj", "sfsqhzjkk", "sqhzjkkys", "created_uid", "gwszdd", "sfyqjzgc", "jrsfqzys", "jrsfqzfy"
]
defaultKeys = [
"date", "created", "id",
]
def login(username: str, password: str):
resp = session.post("https://app.bupt.edu.cn/uc/wap/login/check", data={
"username": username,
"password": password,
})
if resp.json()["e"] == 0:
return True
else:
print(resp.text)
return False
def check(username: str, password: str):
if login(username, password):
print(username, "登录成功")
else:
print(username, "登录失败")
return
resp = session.get("https://app.bupt.edu.cn/ncov/wap/default/index")
matchDefault = re.findall(r'var def = (.*);\n', resp.text)
if (len(matchDefault) == 0):
print("获取默认信息失败")
return
default = json.loads(matchDefault[0])
matchOld = re.findall(r'oldInfo: (.*),\n', resp.text)
if (len(matchOld) == 0):
print("获取上次信息失败")
return
oldInfo = json.loads(matchOld[0])
data = {}
for k in oldInfo:
data[k] = oldInfo.get(k, "")
for k in defaultKeys:
data[k] = default.get(k, "")
resp = session.post(
"https://app.bupt.edu.cn/ncov/wap/default/save", data=data)
j = resp.json()
if j.get("e", 1) == 0:
print("填报成功")
else:
print("填报失败", j.get("m", ""))
if __name__ == "__main__":
with open("./users.txt") as f:
users = f.read().split("\n")
for u in users:
try:
if u != "":
username, password = u.split(" ")
check(username, password)
except Exception as e:
print(e)

1
check/users.txt

@ -0,0 +1 @@ @@ -0,0 +1 @@
2019111111 11111111
Loading…
Cancel
Save