A small utility for monitoring the University of Science and Technology of China (USTC) graduate lecture portal. The watcher authenticates against the CAS login page, loads the lecture selection table, tracks the records in a local cache, and notifies you when new lectures are published.
- CAS login automation for
https://yjs1.ustc.edu.cn/gsapp/ - HTML parsing of the academic report selection table
- JSON cache to avoid duplicate notifications
- Optional SMTP notification when new lectures are found
- Continuous watch loop with configurable polling interval
Create a virtual environment and install the dependencies:
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtIf you prefer not to create a requirements file, install the minimal dependencies manually:
pip install requests beautifulsoup4The watcher uses environment variables for credentials and optional email notifications:
| Variable | Description |
|---|---|
USTC_USERNAME |
Your USTC campus ID used for CAS login. |
USTC_PASSWORD |
Password associated with the campus ID. |
LECTURE_NOTIFY_EMAIL |
(Optional) Recipient email for notifications. |
LECTURE_SMTP_SERVER |
(Optional) SMTP server hostname. Required if LECTURE_NOTIFY_EMAIL is set. |
LECTURE_SMTP_PORT |
(Optional) SMTP port; defaults to 587. |
LECTURE_SMTP_USERNAME |
(Optional) SMTP username for authenticated SMTP servers. |
LECTURE_SMTP_PASSWORD |
(Optional) SMTP password. |
LECTURE_POLL_INTERVAL |
(Optional) Poll interval in seconds; defaults to 600. |
Credentials are not stored on disk by default. If you need persistent
configuration, consider exporting the variables in your shell profile or using a
.env loader.
Run the watcher with Python once the environment variables are configured:
export USTC_USERNAME="your_id"
export USTC_PASSWORD="your_password"
python scripts/lecture_watcher.pyThe script will:
- Log into the CAS portal using the provided credentials.
- Establish a session with the graduate school service portal.
- Load the academic report selection page and parse the lecture table.
- Compare the result with
storage/lectures.jsonto detect new or modified entries. - Emit an info-level log message and optional email whenever updates are detected.
- Sleep for the configured interval and repeat the cycle.
To run the watcher in the background you can rely on process managers (e.g.
systemd, supervisor, tmux) or containerize the script. The process emits
structured logs which make it suitable for integration with log aggregators.
scripts/lecture_watcher.pycontains the main implementation.- The module can be imported and the
LectureWatcherclass used directly in custom tooling if you prefer to integrate it into a larger project.
To validate the script without hitting the live service you can mock the network
requests by patching CASClient.session with a custom object that returns saved
HTML fixtures.
This project is intended for personal use. Please respect the university's terms of service and rate limits when running the watcher.