├── .gitignore ├── id.csv ├── images ├── 1.png ├── 2.png ├── 3.png └── 4.png ├── LICENSE ├── README.md └── report.py /.gitignore: -------------------------------------------------------------------------------- 1 | id.csv 2 | -------------------------------------------------------------------------------- /id.csv: -------------------------------------------------------------------------------- 1 | name_id,eai-sess,at_school,custom_area,area -------------------------------------------------------------------------------- /images/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/W0n9/BUCT_COVID-19_Report/HEAD/images/1.png -------------------------------------------------------------------------------- /images/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/W0n9/BUCT_COVID-19_Report/HEAD/images/2.png -------------------------------------------------------------------------------- /images/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/W0n9/BUCT_COVID-19_Report/HEAD/images/3.png -------------------------------------------------------------------------------- /images/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/W0n9/BUCT_COVID-19_Report/HEAD/images/4.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 W0n9 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BUCT_COVID-19_Report 2 | 3 | 基于 Python3 的适用于北京化工大学的 COVID-19 自动填报脚本 4 | 现已适配2022年打卡方式 5 | **NEW**: 更新不需要抓包获取cookies的方式 6 | 7 | 项目用于学习交流,仅用于各项无异常时打卡,如有身体不适等情况还请自行如实打卡 8 | 9 | ## 使用方式 10 | 11 | 1. ~~在企业微信进入“返校打卡”页面,抓包获得'cookies',~~ 12 | 打开企业微信时,按`Ctrl+Alt+Shift+D`组合键进入调试模式,进入“返校打卡”页面,使用DevTools抓包获得`cookies`,修改`id.csv`内的`eai-sess`列(分隔符为`,`) 13 | ``` 14 | name_id,eai-sess,at_school,custom_area,area 15 | ``` 16 | 2. 修改 `report.py` 内的经纬度(可选) 17 | 3. ~~填写 `province` 和 `city`避免报 `上报位置不能为空` 错误;`address`为您的具体地址,如`广东省广州市海珠区阅江西路222号广州塔`;`area`为您所在的行政区域,如`广东省 广州市 海珠区`~~ 18 | 4. 如果是留校同学,请修改`id.csv`内的`at_school`列为1,程序将会自动上报位置为`北京市朝阳区北三环东路15号北京化工大学` 19 | 5. 如果是离校但需要自定义打卡位置同学,请保持`id.csv`内的`at_school`列为0,并修改`custom_area`列为1,且在`area`列内填写您所在的行政区域,以空格分隔行政级别,如`广东省 广州市 海珠区`,或直辖市`上海市 上海市 静安区` 20 | 6. 如果是离校但只需要~~形式主义一下~~打卡的同学,请保持`id.csv`内的`at_school`列和`custom_area`列为0~~,程序会带您去一个安全的景点旅游XD~~ 21 | 7. 安装所需依赖:`pip3 install requests` (Windows下请用命令提示符输入,报错请检查PATH;Linux在shell直接打就行) 22 | 23 | >>`若提示'pip' 不是内部或外部命令,也不是可运行的程序或批处理文件,请加入PATH`具体可参考[CSDN博客](https://blog.csdn.net/AlbenXie/article/details/79054409) 24 | 25 | 5. 执行 `report.py` 26 | 27 | ## 抓包方法 28 | 29 | ### 抓包方法视频教程 [BiliBili](https://www.bilibili.com/video/BV1bC4y147Pj) [Youtube](https://www.youtube.com/watch?v=oAiY4iCu9Kk) 30 | 31 | 32 | 可以使用`Fiddler` + `企业微信` 进行抓包获得cookies,需要进入Tools-Options-HTTPS处打开HTTPS流量解密,具体方法可参考[简书](https://www.jianshu.com/p/690eb9bebe3c) 33 | 34 | ![HTTPS设置](images/4.png) 35 | ![Fiddler截图](images/3.png) 36 | 37 | ## 自动化 38 | ### Window:任务计划程序 39 | 40 | 1. 在 windows搜索:“计算机管理”,进入如下界面: 41 | ![搜索界面](images/1.png) 42 | ![应用界面](images/2.png) 43 | 2. 选择 系统工具 --> 任务计划程序 ,点击右侧的 “创建基本任务”,进入如下界面 44 | 3. 参考这篇博文:https://blog.csdn.net/u012849872/article/details/82719372 45 | 46 | ### Linux:使用 Crontab 47 | 48 | ```shell script 49 | sudo crontab -e 50 | ``` 51 | 52 | 每天早晨 6 点上报 53 | 54 | ```shell script 55 | 0 6 * * * python3 report.py 56 | ``` 57 | 58 | 每两小时上报一次并追加输出到日志 59 | 60 | ```shell script 61 | 0 */2 * * * python3 /root/report/report.py >> report.log 62 | ``` 63 | -------------------------------------------------------------------------------- /report.py: -------------------------------------------------------------------------------- 1 | import csv 2 | import json 3 | import time 4 | import requests 5 | 6 | filename = "id.csv" # 最好填写csv绝对路径,默认为$PWD工作路径 7 | url = "https://eai.buct.edu.cn/ncov/wap/default/save" 8 | 9 | 10 | def post_and_print(s, url, data, headers, cookies): 11 | result = s.post(url, data=data, headers=headers, cookies=cookies) 12 | print( 13 | time.strftime("%m/%d %H:%M:%S ", time.localtime()) 14 | + name 15 | + " " 16 | + json.loads(result.text)["m"] 17 | ) 18 | 19 | 20 | if __name__ == "__main__": 21 | 22 | # init 23 | s = requests.session() 24 | headers = {} 25 | 26 | # report 27 | cookies = {} 28 | data = { 29 | "sfzx": "0", # 是否在校 30 | "sfzgn": "1", # 所在地点中国大陆 31 | "zgfxdq": "0", # 不在中高风险地区 32 | "buctzctw": "2", # 今日早晨体温范围,36℃-36.9℃ 33 | "buctzwtw": "2", # 今日中午体温范围,36℃-36.9℃ 34 | "buctwjtw": "2", # 今日晚间体温范围,36℃-36.9℃ 35 | "jcjgqr": "0", # 正常,非疑似/确诊 36 | "sfcxtz": "0", # 没有出现发热、乏力、干咳、呼吸困难等症状 37 | "sfjcbh": "0", # 今日是否接触无症状感染/疑似/确诊人群 38 | "mjry": "0", # 今日是否接触密接人员 39 | "csmjry": "0", # 近14日内本人/共同居住者是否去过疫情发生场所 40 | "sfcyglq": "0", # 是否处于观察期 41 | "szsqsfybl": "0", # 所在社区是否有确诊病例 42 | "sfcxzysx": "0", # 是否有任何与疫情相关的, 值得注意的情况 43 | "tw": "1", # 体温范围(下标从 1 开始),此处是36 - 36.5 44 | "area": "西藏自治区 日喀则市 定日县", # 所在区域 45 | "province": "西藏自治区", # 所在省 46 | "city": "日喀则市", # 所在市 47 | "address": "西藏自治区日喀则市定日县珠峰大本营", # 地址 48 | # 'sfcyglq': '0', # 是否处于隔离期 49 | # 'sfyzz': '0', # 是否有症状 50 | # 'askforleave': '0', # 是否请假外出 51 | "qksm": "", # 其他情况 52 | "geo_api_info": { 53 | "type": "complete", 54 | "info": "SUCCESS", 55 | "status": 1, 56 | "Eia": "jsonp_913580_", 57 | "position": { 58 | "O": 113.0270592, # 经度 59 | "P": 22.5524345, # 纬度 60 | "lng": 113.0270592, # 经度 61 | "lat": 22.5524345, # 纬度 62 | }, 63 | "message": "Get+ipLocation+success.Get+address+success.", 64 | "location_type": "ip", 65 | "accuracy": None, 66 | "isConverted": True, 67 | "addressComponent": { 68 | "citycode": "", 69 | "adcode": "", # 行政区划代码 70 | "businessAreas": [], 71 | "neighborhoodType": "", 72 | "neighborhood": "", 73 | "building": "", 74 | "buildingType": "", 75 | "street": "", 76 | "streetNumber": "", 77 | "province": "", # 所在省 78 | "city": "", # 所在市 79 | "district": "", # 所在区 80 | "township": "", # 所在街道 81 | }, 82 | "formattedAddress": "", # 拼接后的地址 83 | "roads": [], 84 | "crosses": [], 85 | "pois": [], 86 | }, 87 | } 88 | 89 | with open(filename, "r", encoding="gb2312") as f: 90 | reader = csv.reader(f) 91 | reader.__next__() 92 | for row in reader: 93 | name = row[0] 94 | cookies["eai-sess"] = row[1] 95 | at_school_status = row[2] 96 | custom_area_status = row[3] 97 | if at_school_status == "1": # 判断在校同学 98 | at_school_data = data.copy() 99 | at_school_data.update( 100 | sfzx="1", 101 | area="北京市 朝阳区", 102 | province="北京市", 103 | city="北京市", 104 | address="北京市朝阳区北三环东路15号北京化工大学", 105 | ) 106 | post_and_print(s, url, at_school_data, headers, cookies) 107 | continue 108 | if custom_area_status == "1": # 判断自定义位置 109 | custom_area_data = data.copy() 110 | custom_area_data.update( 111 | area=row[4], 112 | province=row[4].split()[0], 113 | city=row[4].split()[1], 114 | address=row[4], 115 | ) 116 | post_and_print(s, url, custom_area_data, headers, cookies) 117 | continue 118 | post_and_print(s, url, data, headers, cookies) 119 | --------------------------------------------------------------------------------