84 lines
1.7 KiB
Markdown
84 lines
1.7 KiB
Markdown
# 教务处通知监控工具
|
||
|
||
## 功能特点
|
||
|
||
- 定时监控教务处网站通知
|
||
- 有新通知时自动发送邮件
|
||
- 可配置监控频率(分钟)
|
||
- 状态持久化,记录已发送通知避免重复
|
||
|
||
## 部署步骤
|
||
|
||
### 1. 安装依赖
|
||
|
||
```bash
|
||
pip install -r requirements.txt
|
||
```
|
||
|
||
### 2. 配置
|
||
|
||
编辑 `config.yaml`:
|
||
|
||
```yaml
|
||
monitor:
|
||
url: "https://jwc.your.edu.cn/tzgg.htm" # 改为你的教务处地址
|
||
frequency_minutes: 30 # 监控频率
|
||
encoding: "utf-8"
|
||
|
||
notification:
|
||
smtp_host: "smtp.gmail.com" # 邮件服务器
|
||
smtp_port: 587
|
||
smtp_user: "your_email@gmail.com"
|
||
smtp_password: "your_app_password" # 推荐使用应用专用密码
|
||
to_email: "notify@example.com"
|
||
use_tls: true
|
||
```
|
||
|
||
### 3. 运行
|
||
|
||
```bash
|
||
python main.py
|
||
```
|
||
|
||
### 4. 后台运行(Linux)
|
||
|
||
```bash
|
||
nohup python main.py > output.log 2>&1 &
|
||
```
|
||
|
||
或使用 systemd 服务:
|
||
|
||
```ini
|
||
[Unit]
|
||
Description=JWC Monitor
|
||
After=network.target
|
||
|
||
[Service]
|
||
Type=simple
|
||
User=your_user
|
||
WorkingDirectory=/path/to/project
|
||
ExecStart=/usr/bin/python3 main.py
|
||
Restart=always
|
||
|
||
[Install]
|
||
WantedBy=multi-user.target
|
||
```
|
||
|
||
### 5. 常见邮件服务商 SMTP 设置
|
||
|
||
| 服务商 | SMTP Host | 端口 |
|
||
|--------|-----------|------|
|
||
| Gmail | smtp.gmail.com | 587 |
|
||
| QQ | smtp.qq.com | 587 |
|
||
| 163 | smtp.163.com | 465/994 |
|
||
|
||
**Gmail 提示**:需要开启"应用专用密码"或降低账户安全级别。
|
||
|
||
## 适配不同网站
|
||
|
||
如果抓取不到通知,可能需要调整选择器。参考 `main.py` 中的 `_parse_page` 方法,根据实际网页结构修改选择器。
|
||
|
||
常见问题:
|
||
1. 通知列表在哪个标签里?(ul/div/table)
|
||
2. 每条通知的标题和链接在哪?
|
||
3. 网页编码是什么? |