forked from ywz978020607/BUAAAutoUpdate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathin_school3.0.py
51 lines (40 loc) · 1.55 KB
/
in_school3.0.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
import requests
import re
import time
###########用户需要更改的部分###############
your_name = ''
your_pwd = ''
wechat_key = ''
form_data = ''
###########用户需要更改的部分###############
def wechat_post(text):
url = 'https://sc.ftqq.com/' + wechat_key + '.send?text='+text+time.strftime("%m-%d", time.localtime())
requests.get(url)
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)
# 无论是否登录成功,状态码一般都是 statusCode = 200
# print(f"statusCode = {responseRes.status_code}")
print(f"text = {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_handler(event, context):
result = fillForm(buaaLogin(your_name, your_pwd))
wechat_post(result.text)
return("DONE")