├── .github └── workflows │ └── autocheck.yml ├── README.md ├── checkv2.py ├── daily_statistics ├── daily_statistics.py └── dateBase.xlsx ├── in_school.py ├── in_school2.0.py ├── in_school3.0.py ├── out_school.py ├── out_school2.0.py └── picture ├── daka.jpg └── logo.png /.github/workflows/autocheck.yml: -------------------------------------------------------------------------------- 1 | name: autocheck 2 | 3 | on: 4 | workflow_dispatch: # 手动触发 5 | schedule: 6 | - cron: '0 9 * * *' # 北京时间17点05分 7 | 8 | jobs: 9 | check: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: checkout 13 | uses: actions/checkout@v2 14 | - name: Set up Python 3.8 15 | uses: actions/setup-python@v2 16 | with: 17 | python-version: 3.8 18 | - name: install requirement 19 | run: | 20 | python -m pip install --upgrade pip 21 | pip install requests 22 | - name: check 23 | env: 24 | YOUR_PWD: ${{ secrets.YOUR_PWD }} 25 | TOKEN: ${{ secrets.TOKEN }} 26 | YOUR_NAME: ${{secrets.YOUR_NAME}} 27 | CHAT_ID: ${{secrets.CHAT_ID}} 28 | WECHAT_KEY: ${{secrets.WECHAT_KEY}} 29 | FORM: ${{secrets.FORM}} 30 | run: python checkv2.py 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BUAAAutoUpdate 2 | 北航打卡。 3 | 北京航空航天大学自动填写”疫情防控通“的每日上报信息。 4 | ![Telegram](https://github.com/windiboy/BUAAAutoUpdate/blob/master/picture/logo.png) 5 | 6 | # 2021.03.06 学校打卡系统升级,感谢@Leib-Niz更新的in_school3.0.py 7 | - 使用方法和以前一样,https://app.buaa.edu.cn/site/buaaStudentNcov/index 8 | - 填好之后打开控制台Internet选项,提交后查看form并复制到脚本之中 9 | 10 | # 2020.09.23更新新功能——累计每日晚检未打卡名单 11 | ![Telegram](https://github.com/windiboy/BUAAAutoUpdate/blob/master/picture/daka.jpg) 12 | ## 新增功能 13 | - 可以统计到目前为止未打卡名单 14 | - 使用pyplot做图 15 | - 推送到邮箱 16 | - **需要统一认证账号有查看未打卡名单的权限** 17 | ## 操作步骤 18 | ### 脚本依赖 19 | - Python 3.6 或以上 20 | - requests 21 | - openpyxl 22 | - matplotlib.pyplot 23 | ### 修改py脚本中的个人信息 24 | ```bash 25 | your_name = '统一认证账号' 26 | your_pwd = '统一认证密码' 27 | dir_name = 'C:\\Users\\xxx\\xxx\\xxx\\' #存放数据文件的地址 注意要使用绝对路径 28 | file_name = dir_name+time.strftime("%m-%d", time.localtime()) 29 | dataBase_name = 'dateBase.xlsx' 30 | 31 | msg_from = 'xxx@qq.com' # 发送方邮箱 32 | passwd = 'xxxxx' # 填入发送方邮箱的授权码 33 | msg_to = 'xxxx@qq.com' # 收件人邮箱 34 | ``` 35 | ### 设计定时启动或手动运行 36 | - 运行后邮箱即可收到图片 37 | - dataBase.xlsx即为数据库文件 38 | 39 | # 2020.08.14更新2.0版本 40 | ## 新增功能 41 | - 新增了out_school2.0.py和in_school2.0.py 42 | - 舍弃了selenium,改用更方便的request库 43 | - 可以通过腾讯云函数实现代码托管,参考了这位[同学](https://github.com/kngkngtian/AutoReport) 44 | - 当然也可以只在本地运行,自动运行参考1.0说明文档 45 | 46 | ## 实现原理 47 | - 获取每次提交时的源代码并记录,之后每天按照记录的源代码重复提交 48 | 49 | ## 操作步骤 50 | ### 获取需要提交的信息 51 | - 使用chrome浏览器,打开并登录[疫情防控通校外](https://app.buaa.edu.cn/ncov/wap/default/index)/[疫情防控通校内](https://app.buaa.edu.cn/site/ncov/xisudailyup) 52 | - 如果无法获取定位,可以参考[Chrome 自定位置](https://blog.csdn.net/u010844189/article/details/81163438)。 53 | - 校外同学:在页面中填好全部信息之后,打开`F12`控制台,输入`vm.save()`,然后查看`network`标签中的`save`项。点击后查看`Headers`标签,点击`Form Data`右侧的`view source`,复制备用。 54 | - 校内同学:在页面中填好全部信息之后,点击提交,然后查看`network`标签中的`save`项。点击后查看`Headers`标签,点击`Form Data`右侧的`view source`,复制备用。 55 | 56 | ### 修改py脚本中的个人信息 57 | 将个人账号密码、Server酱key和上面获取到的form_data替换掉对应的内容 58 | ```bash 59 | your_name = '统一认证账号' 60 | your_pwd = '统一认证密码' 61 | wechat_key = '填入你的Server酱key' 62 | form_data = '复制的form_data' 63 | ``` 64 | 65 | ### 新建云函数 66 | 这里以腾讯云为例,进入[腾讯云函数页面](https://console.cloud.tencent.com/scf),点击侧栏的`函数服务`,新建一个函数。 67 | 函数名称随意,运行环境选择`python3.6`,创建方式选择`空白函数`即可,点击完成。 68 | 选择`函数代码`标签,将修改完的python脚本代码替换掉原来的hello world代码,选择`保存并测试`。测试绿色表明成功同时会收到微信推送提示,失败的话请检查相关字符串是否正确。 69 | ### 设置触发器 70 | 选择左侧`触发管理`,创建一个新的触发器。选择`定时触发`,出发周期自定义,自己根据想要自动提交的时间输入Cron数据即可。推荐使用`0 1 0,8 * * * *`即可,该触发时间为每天的0:01和8:01,防止因为系统或某方面原因而失败。 71 | 72 | ### Enjoy 73 | 74 | # 以下是1.0版本的内容 75 | ## 使用前提 76 | 77 | - 该脚本的工作方式为:通过ChromeDrive模拟打开填报页面,模拟鼠标点击**位置、选择温度**并提交 78 | - 分为校外版本**out_school.py**和校内版本**in_school.py** 79 | - **本脚本参考了这位[同学](https://github.com/buaalzm/fuckdaka),仅为学习开发使用,请勿瞒报谎报疫情信息,否则后果自负** 80 | 81 | ## 脚本依赖 82 | 83 | - Python 3.6 或以上 84 | - selenium库(以及对应浏览器的驱动程序) 85 | 86 | **注:** 如果您需要让该脚本定期自动运行: 87 | 88 | 1. Linux/macOS 用户可以配置 cron 等工具。参考教程: 89 | 1. https://www.ibm.com/developerworks/cn/education/aix/au-usingcron/index.html 90 | 2. https://crontab.guru/ 91 | 2. Windows 用户可以使用系统的「任务计划」功能。参考教程: 92 | 1. https://www.cnblogs.com/jjliu/p/11505720.html 93 | 94 | ## windows 10环境配置 95 | - 建议使用Anaconda进行环境配置 96 | 1. [下载并安装Anaconda](https://www.anaconda.com/products/individual),需要记住安装位置。 97 | 2. 创建虚拟环境并激活,安装selenium库 98 | ```bash 99 | conda create -n web python=3.6 100 | conda activate web 101 | conda install selenium 102 | ``` 103 | 3. [安装ChromeDrive](https://chromedriver.chromium.org/downloads),注意版本对应:如果您使用的是Chrome版本85,请下载ChromeDriver 85.0.4183.38 104 | - 需要将解压出来的chromedriver.exe分别放到**chrome浏览器的根目录和Anaconda对应虚拟环境的根目录** 105 | - 例如C:\Program Files (x86)\Google\Chrome\Application D:\Anaconda\envs\web 106 | 107 | ## 将运行结果推送到微信上 108 | 109 | 本脚本支持使用「[Server 酱](https://sc.ftqq.com/3.version)」将运行结果通过微信推送到手机上。 110 | 111 | 您只需要根据[官网上的介绍](https://sc.ftqq.com/3.version),在「Server 酱」官网登录并绑定微信后,将网站提供的 SCKEY 作为参数传入脚本文件即可: 112 | 113 | ```bash 114 | wechat_key = 'your key' 115 | ``` 116 | 117 | ## 运行示例 118 | 119 | 假设您北航统一认证的账户和密码是: 120 | 121 | - **用户名:** user 122 | - **密码:** password 123 | 124 | 修改您所需要用的脚本文件,例如out_school.py 125 | ```bash 126 | user_name = 'user' 127 | pwd = 'password' 128 | ``` 129 | 运行即可 130 | 131 | ## 版权 132 | 133 | 使用 MIT 协议发布,著作权由代码的贡献者所有。 134 | -------------------------------------------------------------------------------- /checkv2.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import re 3 | import time 4 | import os 5 | 6 | your_name = os.environ["YOUR_NAME"] 7 | your_pwd = os.environ["YOUR_PWD"] 8 | wechat_key = os.environ["WECHAT_KEY"] 9 | token = os.environ["TOKEN"] 10 | chat_id = os.environ["CHAT_ID"] 11 | form_data = os.environ["FORM"] 12 | 13 | def bot_post(text): 14 | if wechat_key != "": 15 | url1 = 'https://sctapi.ftqq.com/' + wechat_key + '.send?title=check_ok' + '&desp='+text+time.strftime("%m-%d", time.localtime()) 16 | re_result = requests.get(url1) 17 | print(re_result.text) 18 | if token != "": 19 | url2 = 'https://api.telegram.org/bot'+token+'/sendMessage?chat_id='+chat_id+'&text='+text+time.strftime("%m-%d", time.localtime()) 20 | re_result = requests.get(url2) 21 | print(re_result.text) 22 | 23 | 24 | def buaaLogin(user_name, password): 25 | print("统一认证登录") 26 | 27 | postUrl = "https://app.buaa.edu.cn/uc/wap/login/check" 28 | postData = { 29 | "username": user_name, 30 | "password": password, 31 | } 32 | responseRes = requests.post(postUrl, data=postData) 33 | print(responseRes.text) 34 | return responseRes 35 | 36 | 37 | def fillForm(res): 38 | s = requests.session() 39 | headers = { 40 | 'Accept': 'application/json, text/javascript, */*; q=0.01', 41 | 'Referer': 'https://app.buaa.edu.cn/site/buaaStudentNcov/index', 42 | 'X-Requested-With': 'XMLHttpRequest', 43 | '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', 44 | 'Content-Type': 'application/x-www-form-urlencoded', 45 | 'Cookie': res.headers['set-cookie'] 46 | } 47 | r = s.post('https://app.buaa.edu.cn/buaaxsncov/wap/default/save', data=form_data, headers=headers) 48 | return r 49 | 50 | 51 | def main(): 52 | result = fillForm(buaaLogin(your_name, your_pwd)) 53 | print(result.text) 54 | bot_post(result.text) 55 | return("DONE") 56 | main() 57 | -------------------------------------------------------------------------------- /daily_statistics/daily_statistics.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import requests 3 | import re 4 | import time 5 | import openpyxl 6 | import matplotlib.pyplot as plt 7 | from matplotlib.pyplot import MultipleLocator 8 | import smtplib 9 | from email.mime.text import MIMEText 10 | from email.mime.multipart import MIMEMultipart 11 | from email.mime.image import MIMEImage 12 | 13 | your_name = '统一认证账号' 14 | your_pwd = '统一认证密码' 15 | dir_name = 'C:\\Users\\xxx\\xxx\\xxx\\' #存放数据文件的地址 注意要使用绝对路径 16 | file_name=dir_name+time.strftime("%m-%d", time.localtime()) 17 | dataBase_name = 'dateBase.xlsx' 18 | 19 | msg_from = 'xxx@qq.com' # 发送方邮箱 20 | passwd = 'xxxxx' # 填入发送方邮箱的授权码 21 | msg_to = 'xxxx@qq.com' # 收件人邮箱 22 | 23 | 24 | def buaaLogin(user_name, password): 25 | print("统一认证登录") 26 | 27 | postUrl = "https://app.buaa.edu.cn/uc/wap/login/check" 28 | postData = { 29 | "username": user_name, 30 | "password": password, 31 | } 32 | responseRes = requests.post(postUrl, data=postData) 33 | # 无论是否登录成功,状态码一般都是 statusCode = 200 34 | # print(f"statusCode = {responseRes.status_code}") 35 | print(f"text = {responseRes.text}") 36 | # print(responseRes.headers['set-cookie']) 37 | return responseRes 38 | 39 | 40 | def sendEmail(res): 41 | s = requests.session() 42 | date = time.strftime("%Y-%m-%d", time.localtime()) 43 | headers = { 44 | 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', 45 | 'Referer': 'https://app.buaa.edu.cn/site/epideAll/epideType?type=weishangbao&date='+date+'&group_id=1&group_type=1&flag=2', 46 | 'X-Requested-With': 'XMLHttpRequest', 47 | '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', 48 | 'Content-Type': 'application/x-www-form-urlencoded', 49 | 'Cookie': res.headers['set-cookie'] 50 | } 51 | r = s.get('https://app.buaa.edu.cn/xisuncov/wap/buaa/export-download?group_id=1&group_type=1&type=weishangbao&date='+date+'&flag=2', headers=headers) 52 | print(r) 53 | return r 54 | 55 | def dataBase(): 56 | wb1 = openpyxl.load_workbook(file_name+'.xlsx') 57 | ws1 = wb1['Sheet'] 58 | wb2 = openpyxl.load_workbook(dir_name+dataBase_name) 59 | ws2 = wb2['Sheet'] 60 | today =[] 61 | dB = [] 62 | for cell in ws1.iter_cols(1, 2, values_only=True): 63 | today = cell[1:] 64 | for cell in ws2.iter_cols(1, 2, values_only=True): 65 | dB = cell[1:] 66 | 67 | for i in today: 68 | if i in dB: 69 | index2 = dB.index(i)+2 70 | rank = ws2.cell(index2,3).value 71 | ws2.cell(index2,3).value = rank+1 72 | else: 73 | index1 = today.index(i)+2 74 | ws2.append([ws1.cell(index1,1).value, i, 1]) 75 | wb2.save(dataBase_name) 76 | print(file_name+"信息已更新") 77 | return len(today) 78 | 79 | def draw(): 80 | wb2 = openpyxl.load_workbook(dir_name+dataBase_name) 81 | ws2 = wb2['Sheet'] 82 | name = () 83 | cout = () 84 | for cell in ws2.iter_cols(0, 1, values_only=True): 85 | name = cell[1:] 86 | for cell in ws2.iter_cols(2, 3, values_only=True): 87 | cout = cell[1:] 88 | 89 | plt.rcParams['font.sans-serif'] = ['SimHei'] # 显示中文标签 90 | plt.rcParams['axes.unicode_minus'] = False # 这两行需要手动设置 91 | plt.tick_params(labelsize=8) 92 | plt.figure(figsize=(len(name), max(cout)+1)) 93 | plt.plot(name, cout, 'g*-') 94 | for i in range(0,len(name)): 95 | plt.text(name[i], cout[i], cout[i], fontdict={'fontsize': 16, 'color': 'red'}) 96 | plt.title('截止到'+file_name[45:]+'未打卡人数统计') 97 | 98 | plt.savefig(file_name+'.jpg') 99 | print("已保存到"+file_name+".jpg") 100 | # plt.show() 101 | 102 | def sendPic(): 103 | 104 | subject = "截止"+file_name[45:]+"未填报统计" # 主题 105 | msg = MIMEMultipart('related') 106 | content = MIMEText('imageid', 'html', 'utf-8') # 正文 107 | # msg = MIMEText(content) 108 | msg.attach(content) 109 | msg['Subject'] = subject 110 | msg['From'] = msg_from 111 | msg['To'] = msg_to 112 | 113 | file = open(file_name+".jpg", "rb") 114 | img_data = file.read() 115 | file.close() 116 | 117 | img = MIMEImage(img_data) 118 | img.add_header('Content-ID', 'imageid') 119 | msg.attach(img) 120 | 121 | try: 122 | s = smtplib.SMTP_SSL("smtp.qq.com", 465) # 邮件服务器及端口号 123 | s.login(msg_from, passwd) 124 | s.sendmail(msg_from, msg_to, msg.as_string()) 125 | except: 126 | print("发送到邮箱失败") 127 | finally: 128 | print("成功发送到邮箱") 129 | s.quit() 130 | 131 | 132 | if __name__ == "__main__": 133 | 134 | #从返回结果来看,有登录成功 135 | res = sendEmail(buaaLogin(your_name, your_pwd)) 136 | with open(file_name+".xlsx","wb") as file: 137 | file.write(res.content) 138 | print("今日有{}人未打卡".format(dataBase())) 139 | draw() 140 | sendPic() 141 | -------------------------------------------------------------------------------- /daily_statistics/dateBase.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windiboy/BUAAAutoUpdate/00c12cb6b20f51d0005d75b64b0e93f3c0fb6a54/daily_statistics/dateBase.xlsx -------------------------------------------------------------------------------- /in_school.py: -------------------------------------------------------------------------------- 1 | from selenium import webdriver 2 | from selenium.webdriver import ActionChains 3 | import time 4 | 5 | wechat_key = '填入你的Server酱key' 6 | 7 | def wechat_post(text): 8 | url = 'https://sc.ftqq.com/' + wechat_key + '.send?text='+text+time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) 9 | browser.get(url) 10 | 11 | if __name__ == '__main__': 12 | #这里改成你的统一认证用户名和密码 13 | user_name = 'user' 14 | pwd = 'password' 15 | 16 | # 加上这两句话不打开浏览器 17 | option = webdriver.ChromeOptions() 18 | option.add_argument('headless') # 设置option 19 | # 用浏览器打开打卡的网址 20 | browser = webdriver.Chrome(options=option) 21 | browser.get("https://app.buaa.edu.cn/uc/wap/login?redirect=https%3A%2F%2Fapp.buaa.edu.cn%2Fsite%2Fncov%2Fxisudailyup") 22 | 23 | # 输用户名和密码 24 | user_name_input = browser.find_element_by_css_selector('#app > div.content > div:nth-child(1) > input[type=text]') 25 | user_name_input.send_keys(user_name) 26 | user_pwd_input = browser.find_element_by_css_selector('#app > div.content > div:nth-child(2) > input[type=password]') 27 | user_pwd_input.send_keys(pwd) 28 | 29 | # 然后点击登录按钮 30 | login_button = browser.find_element_by_css_selector('#app > div.btn') 31 | ActionChains(browser).move_to_element(login_button).click(login_button).perform() 32 | print('点击登陆') 33 | 34 | # 跳转并点击获取位置按钮 35 | # 这样写是为了等待跳转页面加载出来 36 | while True: 37 | try: 38 | location_button = browser.find_element_by_css_selector('body > div.item-buydate.form-detail2.ncov-page > div > div > section > div.form > ul > li:nth-child(4) > div.text > input[type=text]') 39 | break 40 | except: 41 | time.sleep(5) 42 | # browser.get("https://app.buaa.edu.cn/site/ncov/xisudailyup") 43 | 44 | ActionChains(browser).move_to_element(location_button).click(location_button).perform() 45 | print('获取位置') 46 | 47 | 48 | # 选择温度 49 | temperature_button = browser.find_element_by_css_selector('body > div.item-buydate.form-detail2.ncov-page > div > div > section > div.form > ul > li:nth-child(5) > div > div > div:nth-child(2)') 50 | ActionChains(browser).move_to_element(temperature_button).click(temperature_button).perform() 51 | print('选择温度') 52 | 53 | # 点击提交 54 | submit_button = browser.find_element_by_css_selector('body > div.item-buydate.form-detail2.ncov-page > div > div > section > div.list-box > div > a') 55 | ActionChains(browser).move_to_element(submit_button).click(submit_button).perform() 56 | print('点击提交') 57 | 58 | time.sleep(1) 59 | # 确定 60 | while True: 61 | try: 62 | confirm_button = browser.find_element_by_css_selector('#wapcf > div > div.wapcf-btn-box > div.wapcf-btn.wapcf-btn-ok') 63 | print('提交成功') 64 | break 65 | except: 66 | try: 67 | confirm_button = browser.find_element_by_css_selector('#wapat > div > div.wapat-btn-box > div') 68 | print('今天已提交过') 69 | break 70 | except: 71 | time.sleep(0.5) 72 | ActionChains(browser).move_to_element(confirm_button).click(confirm_button).perform() 73 | wechat_post('提交成功') 74 | 75 | time.sleep(1) 76 | browser.quit() 77 | -------------------------------------------------------------------------------- /in_school2.0.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import re 3 | import time 4 | 5 | ###########用户需要更改的部分############### 6 | your_name = '统一认证账号' 7 | your_pwd = '统一认证密码' 8 | wechat_key = '填入你的Server酱key' 9 | form_data = '复制的form_data' 10 | ###########用户需要更改的部分############### 11 | 12 | def wechat_post(text): 13 | url = 'https://sc.ftqq.com/' + wechat_key + '.send?text='+text+time.strftime("%m-%d", time.localtime()) 14 | requests.get(url) 15 | 16 | 17 | def buaaLogin(user_name, password): 18 | print("统一认证登录") 19 | 20 | postUrl = "https://app.buaa.edu.cn/uc/wap/login/check" 21 | postData = { 22 | "username": user_name, 23 | "password": password, 24 | } 25 | responseRes = requests.post(postUrl, data=postData) 26 | # 无论是否登录成功,状态码一般都是 statusCode = 200 27 | # print(f"statusCode = {responseRes.status_code}") 28 | print(f"text = {responseRes.text}") 29 | return responseRes 30 | 31 | 32 | def fillForm(res): 33 | s = requests.session() 34 | headers = { 35 | 'Accept': 'application/json, text/javascript, */*; q=0.01', 36 | 'Referer': 'https://app.buaa.edu.cn/site/ncov/xisudailyup', 37 | 'X-Requested-With': 'XMLHttpRequest', 38 | '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', 39 | 'Content-Type': 'application/x-www-form-urlencoded', 40 | 'Cookie': res.headers['set-cookie'] 41 | } 42 | r = s.post('https://app.buaa.edu.cn/xisuncov/wap/open-report/save', data=form_data, headers=headers) 43 | return r 44 | 45 | 46 | def main_handler(event, context): 47 | result = fillForm(buaaLogin(your_name, your_pwd)) 48 | wechat_post(result.text) 49 | return("DONE") 50 | 51 | -------------------------------------------------------------------------------- /in_school3.0.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import re 3 | import time 4 | 5 | ###########用户需要更改的部分############### 6 | your_name = '' 7 | your_pwd = '' 8 | wechat_key = '' 9 | form_data = '' 10 | 11 | ###########用户需要更改的部分############### 12 | 13 | def wechat_post(text): 14 | url = 'https://sc.ftqq.com/' + wechat_key + '.send?text='+text+time.strftime("%m-%d", time.localtime()) 15 | requests.get(url) 16 | 17 | 18 | def buaaLogin(user_name, password): 19 | print("统一认证登录") 20 | 21 | postUrl = "https://app.buaa.edu.cn/uc/wap/login/check" 22 | postData = { 23 | "username": user_name, 24 | "password": password, 25 | } 26 | responseRes = requests.post(postUrl, data=postData) 27 | # 无论是否登录成功,状态码一般都是 statusCode = 200 28 | # print(f"statusCode = {responseRes.status_code}") 29 | print(f"text = {responseRes.text}") 30 | return responseRes 31 | 32 | 33 | def fillForm(res): 34 | s = requests.session() 35 | headers = { 36 | 'Accept': 'application/json, text/javascript, */*; q=0.01', 37 | 'Referer': 'https://app.buaa.edu.cn/site/buaaStudentNcov/index', 38 | 'X-Requested-With': 'XMLHttpRequest', 39 | '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', 40 | 'Content-Type': 'application/x-www-form-urlencoded', 41 | 'Cookie': res.headers['set-cookie'] 42 | } 43 | r = s.post('https://app.buaa.edu.cn/buaaxsncov/wap/default/save', data=form_data, headers=headers) 44 | return r 45 | 46 | 47 | def main_handler(event, context): 48 | result = fillForm(buaaLogin(your_name, your_pwd)) 49 | wechat_post(result.text) 50 | return("DONE") 51 | 52 | -------------------------------------------------------------------------------- /out_school.py: -------------------------------------------------------------------------------- 1 | from selenium import webdriver 2 | from selenium.webdriver import ActionChains 3 | import time 4 | 5 | wechat_key = '你的Server酱key' 6 | 7 | 8 | def wechat_post(text): 9 | url = 'https://sc.ftqq.com/' + wechat_key + '.send?text='+text+time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) 10 | browser.get(url) 11 | 12 | 13 | if __name__ == '__main__': 14 | #这里改成你的统一认证用户名和密码 15 | user_name = 'user' 16 | pwd = 'password' 17 | 18 | # 加上这两句话不打开浏览器 19 | option = webdriver.ChromeOptions() 20 | #option.add_argument('headless') # 设置option 21 | # 用浏览器打开打卡的网址 22 | browser = webdriver.Chrome(options=option) 23 | browser.get("https://app.buaa.edu.cn/uc/wap/login?redirect=https%3A%2F%2Fapp.buaa.edu.cn%2Fncov%2Fwap%2Fdefault%2Findex") 24 | 25 | # 输用户名和密码 26 | user_name_input = browser.find_element_by_css_selector('#app > div.content > div:nth-child(1) > input[type=text]') 27 | user_name_input.send_keys(user_name) 28 | user_pwd_input = browser.find_element_by_css_selector('#app > div.content > div:nth-child(2) > input[type=password]') 29 | user_pwd_input.send_keys(pwd) 30 | 31 | # 然后点击登录按钮 32 | login_button = browser.find_element_by_css_selector('#app > div.btn') 33 | ActionChains(browser).move_to_element(login_button).click(login_button).perform() 34 | print('点击登陆') 35 | 36 | # 跳转并点击获取位置按钮 37 | # 这样写是为了等待跳转页面加载出来 38 | while True: 39 | try: 40 | location_button = browser.find_element_by_css_selector('body > div.item-buydate.form-detail2 > div > div > section > div.form > ul > li:nth-child(7) > div > input[type=text]') 41 | break 42 | except: 43 | time.sleep(5) 44 | browser.get("https://app.buaa.edu.cn/ncov/wap/default/index") 45 | 46 | ActionChains(browser).move_to_element(location_button).click(location_button).perform() 47 | print('获取位置') 48 | 49 | 50 | # 选择温度 51 | temperature_button = browser.find_element_by_css_selector('body > div.item-buydate.form-detail2 > div > div > section > div.form > ul > li:nth-child(9) > div > div > div:nth-child(2)') 52 | ActionChains(browser).move_to_element(temperature_button).click(temperature_button).perform() 53 | print('选择温度') 54 | 55 | # 点击提交 56 | submit_button = browser.find_element_by_css_selector('body > div.item-buydate.form-detail2 > div > div > section > div.list-box > div > a') 57 | ActionChains(browser).move_to_element(submit_button).click(submit_button).perform() 58 | print('点击提交') 59 | 60 | time.sleep(1) 61 | # 确定 62 | while True: 63 | try: 64 | confirm_button = browser.find_element_by_css_selector('#wapcf > div > div.wapcf-btn-box > div.wapcf-btn.wapcf-btn-ok') 65 | print('提交成功') 66 | break 67 | except: 68 | try: 69 | confirm_button = browser.find_element_by_css_selector('#wapat > div > div.wapat-btn-box > div') 70 | print('今天已提交过') 71 | break 72 | except: 73 | time.sleep(0.5) 74 | ActionChains(browser).move_to_element(confirm_button).click(confirm_button).perform() 75 | wechat_post('提交成功') 76 | 77 | time.sleep(1) 78 | browser.quit() 79 | -------------------------------------------------------------------------------- /out_school2.0.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import re 3 | import time 4 | 5 | ###########用户需要更改的部分############### 6 | your_name = '统一认证账号' 7 | your_pwd = '统一认证密码' 8 | wechat_key = '填入你的Server酱key' 9 | form_data = '复制的form_data' 10 | ###########用户需要更改的部分############### 11 | 12 | def wechat_post(text): 13 | url = 'https://sc.ftqq.com/' + wechat_key + '.send?text='+text+time.strftime("%m-%d", time.localtime()) 14 | requests.get(url) 15 | 16 | def buaaLogin(user_name, password): 17 | print("统一认证登录") 18 | 19 | postUrl = "https://app.buaa.edu.cn/uc/wap/login/check" 20 | postData = { 21 | "username": user_name, 22 | "password": password, 23 | } 24 | responseRes = requests.post(postUrl, data=postData) 25 | print(f"text = {responseRes.text}") 26 | return responseRes 27 | 28 | 29 | def fillForm(res): 30 | s = requests.session() 31 | day = time.strftime("%Y%m%d", time.localtime()) 32 | headers = { 33 | 'Accept': 'application/json, text/javascript, */*; q=0.01', 34 | 'Referer': 'https://app.buaa.edu.cn/ncov/wap/default/index', 35 | 'X-Requested-With': 'XMLHttpRequest', 36 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36 Edg/83.0.478.45', 37 | 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 38 | 'Cookie': res.headers['set-cookie'] 39 | } 40 | data = re.sub(r'date=\d{8}', 'data=' + day, form_data) 41 | r = s.post('https://app.buaa.edu.cn/ncov/wap/default/save', data=data, headers=headers) 42 | return r 43 | 44 | 45 | def main_handler(event, context): 46 | result = fillForm(buaaLogin(your_name, your_pwd)) 47 | wechat_post(result.text) 48 | return("DONE") 49 | -------------------------------------------------------------------------------- /picture/daka.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windiboy/BUAAAutoUpdate/00c12cb6b20f51d0005d75b64b0e93f3c0fb6a54/picture/daka.jpg -------------------------------------------------------------------------------- /picture/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/windiboy/BUAAAutoUpdate/00c12cb6b20f51d0005d75b64b0e93f3c0fb6a54/picture/logo.png --------------------------------------------------------------------------------