Examples¶
All example scripts live in the examples/ directory and write their output
to examples/output/ (gitignored — real data never enters version control).
Fetch personal timetable¶
Downloads and saves the current-semester personal course schedule.
Run:
What it does:
- Logs in with
TJU_USER/TJU_PASS - Detects the current semester automatically
- Calls
client.schedule(semester=semester) - Prints a human-readable course list (name, credits, campus, class slots)
- Serialises the full schedule with
Course.Schema(many=True).dump(...)and writes it toexamples/output/schedule_<semester>.json
Sample output:
============================================================
学生: 张三 (1234567890)
类型: GRADUATE
学期: 25262
============================================================
共 3 门课程:
[ 1] 随机过程基础 (2.0 学分)
课号: S131GA04 班级: 05749
校区: 北洋园校区 周次: 1-8
上课: 周一 第 3~4 节 44楼A区211 [王勇]
上课: 周三 第 1~2 节 44楼A区211 [王勇]
Fetch full course library (UG + GS)¶
Downloads the entire public course catalogue — both undergraduate and graduate libraries — and merges them into one file.
Run:
What it does:
- Logs in and detects the current semester
- Queries the undergraduate library (
project_id=1) page by page (1000 courses/page) - Queries the graduate library (
project_id=22) page by page - Tags each record with
student_type: "undergraduate" | "graduate" - Serialises all records with
LibCourse.Schema(many=True).dump(...)and writesexamples/output/courses_<semester>.json
Distinguishing UG vs. GS courses:
| Signal | Undergraduate | Graduate |
|---|---|---|
student_type field (injected) |
"undergraduate" |
"graduate" |
course_id prefix |
Numeric (2xxxxxx) |
S… or B… |
selected / limit fields |
Populated | null (12-col format) |
Sample output: