-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathcheckv2.py
More file actions
56 lines (47 loc) · 1.77 KB
/
checkv2.py
File metadata and controls
56 lines (47 loc) · 1.77 KB
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
import requests
import re
import time
import os
your_name = os.environ["YOUR_NAME"]
your_pwd = os.environ["YOUR_PWD"]
wechat_key = os.environ["WECHAT_KEY"]
token = os.environ["TOKEN"]
chat_id = os.environ["CHAT_ID"]
form_data = os.environ["FORM"]
def bot_post(text):
if wechat_key != "":
url1 = 'https://sctapi.ftqq.com/' + wechat_key + '.send?title=check_ok' + '&desp='+text+time.strftime("%m-%d", time.localtime())
re_result = requests.get(url1)
print(re_result.text)
if token != "":
url2 = 'https://api.telegram.org/bot'+token+'/sendMessage?chat_id='+chat_id+'&text='+text+time.strftime("%m-%d", time.localtime())
re_result = requests.get(url2)
print(re_result.text)
def buaaLogin(user_name, password):
print("统一认证登录")
postUrl = "https://app.buaa.edu.cn/uc/wap/login/check"
postData = {
"username": user_name,
"password": password,
}
responseRes = requests.post(postUrl, data=postData)
print(responseRes.text)
return responseRes
def fillForm(res):
s = requests.session()
headers = {
'Accept': 'application/json, text/javascript, */*; q=0.01',
'Referer': 'https://app.buaa.edu.cn/site/buaaStudentNcov/index',
'X-Requested-With': 'XMLHttpRequest',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36',
'Content-Type': 'application/x-www-form-urlencoded',
'Cookie': res.headers['set-cookie']
}
r = s.post('https://app.buaa.edu.cn/buaaxsncov/wap/default/save', data=form_data, headers=headers)
return r
def main():
result = fillForm(buaaLogin(your_name, your_pwd))
print(result.text)
bot_post(result.text)
return("DONE")
main()