Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
21953b9
revert, 使用requests提交
BlueFisher Mar 17, 2022
05a53dd
更新自动打开时间
BlueFisher Mar 19, 2022
c6ee1c4
增加校区
BlueFisher Mar 20, 2022
9849a84
修复历史校区信息获取错误
BlueFisher Mar 21, 2022
54ddb60
适配2022-03-22版本,修改字段
BlueFisher Mar 22, 2022
3004a7a
修复图片上传接口
BlueFisher Mar 22, 2022
e484381
增加拉取远程代码
BlueFisher Mar 23, 2022
e8f4778
test github action
BlueFisher Mar 23, 2022
d5f4ab1
修复openvpn+pull
BlueFisher Mar 23, 2022
7ab9597
修改readme
BlueFisher Mar 23, 2022
516389f
更新readme
BlueFisher Mar 24, 2022
95ec6af
更新readme
BlueFisher Mar 24, 2022
3258193
重要更新
BlueFisher Mar 24, 2022
57b2d46
更改时间
BlueFisher Mar 26, 2022
795ce1c
feat: 连接学校VPN失败重连功能
panghaibin Mar 27, 2022
a22767b
add permission access
Mar 27, 2022
433805e
Pull Request #81: feat: 新增连接学校VPN失败重连功能
Mar 27, 2022
803a989
添加代理
BlueFisher Mar 27, 2022
988c3a6
修复secrets错误
BlueFisher Mar 27, 2022
7d0451f
精简workflow
BlueFisher Mar 28, 2022
4c46f11
更新readme
BlueFisher Mar 28, 2022
9cf3980
测试模拟IP
panghaibin Mar 28, 2022
f4a42b2
测试模拟IP
panghaibin Mar 28, 2022
96fe1ca
测试模拟IP
panghaibin Mar 28, 2022
6e8b1fe
测试模拟IP
panghaibin Mar 28, 2022
b56b98b
测试模拟IP
panghaibin Mar 28, 2022
a4ff20d
测试模拟IP
panghaibin Mar 28, 2022
e7a1d28
测试模拟IP
panghaibin Mar 28, 2022
a30b94a
测试模拟IP
panghaibin Mar 28, 2022
46bb9a7
测试模拟IP
panghaibin Mar 28, 2022
f0c86a2
测试模拟IP
panghaibin Mar 28, 2022
99ad4f2
修复ovpn.py环境变量名错误
BlueFisher Mar 28, 2022
98eae6e
feat: 新增模拟IP功能,防止IP屏蔽
panghaibin Mar 28, 2022
73cc899
Merge branch 'BlueFisher:master' into master
panghaibin Mar 28, 2022
c28b681
Merge pull request #82 from panghaibin/master
BlueFisher Mar 28, 2022
8bca6e2
默认pull_remote模式
BlueFisher Mar 28, 2022
ef4f05d
修改使用openvpn的条件
BlueFisher Mar 28, 2022
326fe0a
新增隐藏配置
BlueFisher Mar 31, 2022
c759477
Update fstate_generator.py
PeterandAllen Mar 31, 2022
e93e3a1
Merge pull request #83 from PeterandAllen/master
BlueFisher Mar 31, 2022
b8a0a1c
适配JinXXQ
BlueFisher Jun 10, 2022
e4639b7
ddlJieDao
BlueFisher Jul 6, 2022
9124bbb
JinChuSQ
BlueFisher Jul 6, 2022
0491f97
增加“高中低风险地区旅居史”字段
yuany3721 Aug 22, 2022
86fa9c2
适配风险区
BlueFisher Aug 22, 2022
bf6e259
修复选择“不在上海”填报时隐藏选项无内容读取报错问题
yuany3721 Aug 22, 2022
90e00d1
修复非项目目录下执行代码报错
yuany3721 Aug 22, 2022
bf44e91
format before PR
yuany3721 Aug 22, 2022
242fb8c
Merge branch 'master' into master
BlueFisher Aug 22, 2022
fe73c2c
Merge pull request #86 from yuany3721/master
BlueFisher Aug 22, 2022
847dee7
fix: add docker deployment(#84)
Chasing1020 Aug 22, 2022
22a08d1
Merge pull request #87 from Chasing1020/master
BlueFisher Aug 22, 2022
73e161b
feat: ubuntu and pip change source
id-none Aug 23, 2022
b471123
Merge pull request #88 from id-none/patch-2
BlueFisher Aug 25, 2022
a338465
精简镜像体积
BlueFisher Aug 25, 2022
48dcd4c
更新表单 适配曾赴外省市
SYYANI Sep 12, 2022
32fa047
Merge pull request #90 from SYYANI/master
BlueFisher Sep 12, 2022
cae03e2
恢复xingcm,使用环境变量控制
BlueFisher Sep 18, 2022
81903ee
修复secrets
BlueFisher Sep 19, 2022
ab2bddf
environ bug
BlueFisher Sep 21, 2022
f405c29
Report With OpenVPN
BlueFisher Sep 21, 2022
24e9d52
[bugfix] fix exception when getting Xiaoqu in get_last_report
cocochick Sep 22, 2022
0cc7e06
Merge pull request #91 from cocochick/master
BlueFisher Sep 22, 2022
0074846
修复XingCM错误
BlueFisher Oct 17, 2022
6882c6d
Merge branch 'master' of github.com:BlueFisher/SHU-selfreport
BlueFisher Oct 17, 2022
607de2f
Update config.ovpn
KYShek Oct 17, 2022
fcdcce8
Merge pull request #95 from KinYuShek/push-branch
BlueFisher Oct 17, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion .github/vpn/config.ovpn
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,24 @@ client
dev tun
proto tcp

# ROUTING CONFIG

<connection>
remote openvpn.shu.edu.cn 443 #not exist, just for display
remote openvpn1.shu.edu.cn 443
remote openvpn2.shu.edu.cn 443
remote openvpn3.shu.edu.cn 443
remote openvpn4.shu.edu.cn 443
remote openvpn5.shu.edu.cn 443
remote openvpn6.shu.edu.cn 443
remote openvpn7.shu.edu.cn 443
remote openvpn8.shu.edu.cn 443
remote openvpn9.shu.edu.cn 443
</connection>

remote-random
resolv-retry 60

comp-lzo
resolv-retry infinite
nobind
Expand Down Expand Up @@ -49,4 +63,6 @@ ox+1WKF/6d5gXOZOTf0GuJi4JHRojDzb5p/Z6/8gxE9krVsQmfiR3HnaegyTVMle
KzpCQRuEx5rn/uDvV6joYCwy4q0BkQTKGBeUofR2ETlTeC7t6l+GKRPwCQ8BeBvL
e0+RSP6QWl/+flS0qdmtSswuZF98OqAuu6wW2PHXB3auUn77nw==
-----END CERTIFICATE-----
</ca>
</ca>

auth-user-pass secret.txt
102 changes: 74 additions & 28 deletions .github/workflows/report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Auto Report

on:
schedule:
- cron: "0 0,12 * * *"
- cron: "0 19 * * *"
workflow_dispatch:

jobs:
Expand All @@ -12,13 +12,6 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Set up chromedriver
uses: nanasess/setup-chromedriver@v1
- run: |
export DISPLAY=:99
chromedriver --url-base=/wd/hub &
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & # optional

- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
Expand All @@ -29,30 +22,83 @@ jobs:
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Pull Remote
env:
DISABLE_PULL_REMOTE: ${{ secrets.DISABLE_PULL_REMOTE }}
if: env.DISABLE_PULL_REMOTE == ''
run: |
wget -O remote.zip https://github.com/BlueFisher/SHU-selfreport/archive/refs/heads/master.zip
unzip remote.zip

- name: Report Without OpenVPN
if: always()
env:
USERS: ${{ secrets.USERS }}
HTTPS_PROXY: ${{ secrets.HTTPS_PROXY }}
DISABLE_PULL_REMOTE: ${{ secrets.DISABLE_PULL_REMOTE }}
IMG: ${{ secrets.IMG }}
run: |
if [[ $DISABLE_PULL_REMOTE == '' ]]; then
echo "Report from remote";
if python -u SHU-selfreport-master/main.py; then
echo "Report from remote success";
else
echo "Report from remote failed, try using OpenVPN";
echo "USE_OVPN=1" >> $GITHUB_ENV;
fi
else
echo "Report from local";
if python -u main.py; then
echo "Report from local success";
else
echo "Report from local failed, try using OpenVPN";
echo "USE_OVPN=1" >> $GITHUB_ENV;
fi
fi

- name: Configure OpenVPN
env:
users: ${{ secrets.USERS }}
USERS: ${{ secrets.USERS }}
if: env.USE_OVPN != ''
run: |
sudo apt update
sudo apt install -y openvpn openvpn-systemd-resolved
echo "::add-mask::$(python main.py gh-vu)"
echo "::add-mask::$(python main.py gh-vp)"
echo "ovpn_username=$(python main.py gh-vu)" >> $GITHUB_ENV
echo "ovpn_password=$(python main.py gh-vp)" >> $GITHUB_ENV

- name: Connect to VPN
uses: "kota65535/github-openvpn-connect-action@v1"
with:
config_file: .github/vpn/config.ovpn
username: ${{ env.ovpn_username }}
password: ${{ env.ovpn_password }}
sudo apt-get --assume-yes --no-install-recommends install openvpn
python3 ovpn.py
touch vpn.log

- name: Test a VPN connection
timeout-minutes: 1
run: until ping -c1 xk.autoisp.shu.edu.cn; do sleep 2; done
- name: Connect and Test OpenVPN Connection
if: env.USE_OVPN != ''
run: sudo ./ovpn.sh

- name: Report
if: always()
- name: Report With OpenVPN
if: env.USE_OVPN != ''
env:
USERS: ${{ secrets.USERS }}
HTTPS_PROXY: ${{ secrets.HTTPS_PROXY }}
DISABLE_PULL_REMOTE: ${{ secrets.DISABLE_PULL_REMOTE }}
IMG: ${{ secrets.IMG }}
run: |
if [[ $DISABLE_PULL_REMOTE == '' ]]; then
echo "Report from remote";
python -u SHU-selfreport-master/main.py;
else
echo "Report from local";
python -u main.py;
fi

- name: Kill OpenVPN Connection
env:
users: ${{ secrets.USERS }}
run: "python -u main.py"
HTTPS_PROXY: ${{ secrets.HTTPS_PROXY }}
if: env.USE_OVPN != ''
run: |
sudo chmod 777 vpn.log
sudo killall openvpn

- name: Upload VPN logs
uses: actions/upload-artifact@v2
env:
HTTPS_PROXY: ${{ secrets.HTTPS_PROXY }}
if: env.USE_OVPN != ''
with:
name: VPN logs
path: vpn.log
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM ubuntu:20.04

WORKDIR /selfreport

COPY . .

RUN sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list &&\
apt-get update &&\
apt-get install -y python3.8 python3-pip &&\
pip3 install -i https://mirrors.ustc.edu.cn/pypi/web/simple pip -U &&\
pip3 config set global.index-url https://mirrors.ustc.edu.cn/pypi/web/simple &&\
pip3 install -r requirements.txt && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

CMD ["python3", "/selfreport/main.py"]
131 changes: 86 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,72 +1,63 @@
# 上海大学健康之路每日一报/每日两报自动打卡
# 上海大学健康之路每日一报自动打卡

**适配2022-02-28版本,GitHub Actions 新增连接学校VPN再填报功能**
***!!!本项目不支持进行虚假填报!!!仅根据前一天填报内容自动填报,以免遗忘漏报***

**使用selenium提交表单(测试中),自动生成行程码(目前发现行程码只需要图片中有日期文字,且图片长宽比与手机差不多就行)**
程序为python脚本文件,修改配置文件相关信息,设置后台运行脚本,脚本会根据配置文件信息自动进行每日一报。

**适配2022-01-15版,增加随申码。请真实提交随申码与行程码。不信谣不传谣!**
支持github actions服务器。

**适配2021-11-05版,DangSZS**
支持一键补报功能。

**适配2021-11-04版,修复了ShiFSH字段 [issue 51](https://github.com/BlueFisher/SHU-selfreport/issues/51),去除随申码,丰富日志记录,若出现错误,可以当天真实提交一次,等第二天再观察**
支持每日一报。目前在 4:00AM(report_remote)/3:00AM(report) 自动填报一次。

**适配2021-10-08版,获取当天的随申码、行程码。请真实地提交一次随申码、行程码,后续会自动采用之前上传的随申码、行程码**
为了避免过多的配置,感谢[@Lanszhang131](https://github.com/Lanszhang131/DailyReport_SHU)的思路,**利用前一天的报送信息进行填报,所以如果你真实地提交过一次,那每天会重复填报。由于默认是 4:00AM(report_remote)/3:00AM(report) 填报,所以如果你想用真实信息的话第一次在早上6点填报后修改下信息。**

**适配2021-06-28版,更新github action的自动打卡时间**

**适配2021-04-24版,暂不支持党史知识天天学**
## 更新日志

程序为python脚本文件,修改配置文件相关信息,设置后台运行脚本,脚本会根据配置文件信息自动进行每日一报/每日两报。
**目前实现模拟随机IP功能,以规避IP屏蔽;连接学校VPN功能依然保留,若出现提交失败则会尝试连接后再次填报**

支持github actions服务器。
**由于OpenVPN同一时间登录登陆人数过多,现增加失败重连功能,每次连接之间会随机等待一定时间;现默认每次从主项目拉取最新代码填报;增加自定义 `HTTP_PROXY` 与 `DISABLE_PULL_REMOTE` 设置选项,具体使用说明见`用法`**

支持一键补报功能。
**~~由于OpenVPN同一时间登录登陆人数过多,现增加失败重连功能,每次连接之间会随机等待一定时间;增加自定义HTTP_PROXY的环境变量与DISABLE_OPVPN的选项~~**

支持每日一报/每日两报。目前在早9晚9各自动填报一次。
**~~由于OpenVPN同一时间登录登陆人数过多,现随机等待600-1440秒再连接~~**

为了避免过多的配置,感谢[@Lanszhang131](https://github.com/Lanszhang131/DailyReport_SHU)的思路,**利用前一天的报送信息进行填报,所以如果你真实地提交过一次,那每天会重复填报。由于默认是早9晚9填报,所以如果你想用真实信息的话第一次在晚上9点填报后修改下信息。**
**新增 Auto Report from Remote,可以拉取远程最新的代码,不再需要每次更新,每次拉取**

## 免责申明
**适配2022-03-22版本,修改字段(早日解封)**

本项目仅做免费的学术交流使用。
**适配2022-03-20版本,增加校区(早日解封)**

## 用法
**适配2022-02-28版本,GitHub Actions 新增连接学校VPN再填报功能**

### 0. ⭐Star⭐项目😉
~~使用selenium提交表单(测试中),自动生成行程码(目前发现行程码只需要图片中有日期文字,且图片长宽比与手机差不多就行)~~

如果你想获取最新的更新,记得右上角的`watch`
~~适配2022-01-15版,增加随申码。请真实提交随申码与行程码。不信谣不传谣!~~

### 1. 你有服务器,只在自己服务器上进行自动打卡
**适配2021-11-05版,DangSZS**

在 `config.yaml` 中设置所有需要打卡的学号密码
**适配2021-11-04版,修复了ShiFSH字段 [issue 51](https://github.com/BlueFisher/SHU-selfreport/issues/51),去除随申码,丰富日志记录,若出现错误,可以当天真实提交一次,等第二天再观察**

针对Ubuntu,编辑定时执行程序cron
**适配2021-10-08版,获取当天的随申码、行程码。请真实地提交一次随申码、行程码,后续会自动采用之前上传的随申码、行程码**

```bash
crontab -e
```
**适配2021-06-28版,更新github action的自动打卡时间**

加入以下命令:
**适配2021-04-24版,暂不支持党史知识天天学**

```bash
# 程序每天4点执行一次,并将结果输出至shu_report.log
# 注意python的路径,main.py与输出日志shu_report.log的绝对路径
0 4 * * * python -u /xxx/main.py 2>&1 >> /xxx/shu_report.log
```

如果你服务器是UTC时区,则为
## 免责申明

```bash
0 20 * * * python -u /xxx/main.py 2>&1 >> /xxx/shu_report.log
```
本项目仅做免费的学术交流使用。

如果你不确定你服务器的时区,也可以每小时运行一次:
## 用法

```bash
0 * * * * python -u /xxx/main.py 2>&1 >> /xxx/shu_report.log
```
### 0. ⭐Star⭐项目😉

### 2. 你没有服务器,使用 github actions(推荐)
如果你想获取最新的更新,记得右上角的`watch`


### 1. 如果你没有服务器,使用 github actions(推荐)

#### 你第一次Fork

Expand All @@ -78,15 +69,19 @@ crontab -e

`VALUE` 设置为 `学号1,密码1;学号2,密码2` 的格式,注意逗号与分号的区分,学号密码之间用逗号,每两个学号之间用分号,必须是英文半角符号,如果只有一个学号密码则不需要加分号

*如果你有http代理服务器,则建议添加 `HTTPS_PROXY`为你的代理服务器地址,一旦设置 `HTTPS_PROXY` ,则会自动关闭 OpenVPN 连接服务。*

*如果你不想通过拉取主项目的代码来实现自动填报,则建议添加 `DISABLE_PULL_REMOTE` 并设置为 `true` ,这样会禁用拉取主项目代码的模式。*

![](images/secrets.png)

4. 定位到你仓库下的 `Actions` 选项卡,点击 `Enable workflow`
4. 定位到你仓库下的 `Actions` 选项卡中的 `Auto Report`,点击 `Enable workflow`,即可开启自动填报系统。

![](images/enable_actions.png)
![](images/enable_workflow.png)

5. 此时Actions 已经启动完成,每天上午八点(UTC+8)和晚上八点各执行一次,每执行一次会在 `Actions` 选项卡下生成一个报告。
5. 此时 Actions 已经启动完成,每执行一次会在 `Actions` 选项卡下生成一个报告。

如果需要对报送功能进行测试,可以点击 `run workflow` 按钮,立即进行一次运行。
如果需要对报送功能进行测试,可以点击 `Run workflow` 按钮,立即进行一次运行。

![](images/run_workflow.png)

Expand All @@ -104,15 +99,61 @@ crontab -e
![](images/fetch_upstream_02.png)


### 2. 如果你有服务器,只在自己服务器上进行自动打卡

在 `config.yaml` 中设置所有需要打卡的学号密码

针对Ubuntu,编辑定时执行程序cron

```bash
crontab -e
```

加入以下命令:

```bash
# 程序每天4点执行一次,并将结果输出至shu_report.log
# 注意python的路径,main.py与输出日志shu_report.log的绝对路径
0 4 * * * python -u /xxx/main.py 2>&1 >> /xxx/shu_report.log
```

如果你服务器是UTC时区,则为

```bash
0 20 * * * python -u /xxx/main.py 2>&1 >> /xxx/shu_report.log
```

如果你不确定你服务器的时区,也可以每小时运行一次:

```bash
0 * * * * python -u /xxx/main.py 2>&1 >> /xxx/shu_report.log
```

### 3. 使用Docker部署自动打卡

在 `config.yaml` 中设置所有需要打卡的学号密码

```bash
docker build -t selfreport:release .
docker run --name selfreport selfreport:release
```

之后在宿主机编辑Crontab即可

```bash
# crontab -e
0 4 * * * docker start selfreport
```

## 依赖

- python3
- 依赖:
- pyyaml
- beautifulsoup4
- requests
- selenium
- pillow
- rsa

## 感谢

Expand Down
Loading