Skip to main content

五邑大学乘方教务系统 Python SDK(参考实现,理论兼容其他乘方学校)

Project description

wyu-jwxt

Python PyPI License

五邑大学乘方教务系统 Python SDK。以五邑大学为参考实现,base_url 可配,理论兼容其他乘方教务学校。

登录加密算法、接口协议全部逆向自 jxgl.wyu.edu.cn 实测,理论兼容其它乘方教务系统。

📖 详细用法教程 · API 参考

安装

pip install wyu-jwxt

Python >= 3.6。支持 Windows / Linux / macOS。一个命令装好所有依赖(含验证码自动识别)。

快速开始

from wyu_jwxt import Client

client = Client(base_url="https://jxgl.wyu.edu.cn")
client.login("学号", "密码")                       # 自动处理验证码 + AES 加密
schedule = client.get_schedule(2025, 2)             # 课表
grades = client.get_grades(2025, 2)                 # 成绩
exams = client.get_exams(2025, 2)                   # 考试
info = client.get_student_info()                    # 学籍

功能

方法 说明 返回类型
client.login(username, password) 登录 None
client.get_schedule(xn, xq, week=None) 课表查询 List[Course]
client.get_grades(xn=None, xq=None) 成绩查询 List[Grade]
client.get_exams(xn, xq) 考试安排 List[Exam]
client.get_student_info() 学籍卡片 StudentInfo
client.save_session(path) 保存登录态 None
Client.from_session(path) 加载登录态 Client

数据模型

所有 SDK 属性均映射自教务系统原始 JSON/HTML 字段。详见 docs/API.md

Course(课表)

属性 类型 教务字段 示例
name str kcmc 大学英语(2)
teacher str teaxms 小明
classroom str jxcdmc XXX教学楼203
start_time str qssj 08:15:00
end_time str jssj 09:50:00
weekday int jsxq 2 (1=周一 ... 7=周日)
weeks List[int] zc [1,2,3,4,5,7,8,9,...]
term_code str xnxqdm 202502
course_code str kcbh 0400012

Grade(成绩)

属性 类型 教务字段 示例
course_name str kcmc 高等数学
score str zcj 88
credit float xf 5.0,缺失时为 None
term str xnxqmc 2025-2026-2
department str kkbmmc XX学院
nature str xdfsmc 必修
course_code str kcbh 2120410020
student_name str xsxm 张三

Exam(考试)

属性 类型 教务字段 示例
course_name str kcmc 大学物理
date str ksrq 2026-07-06
time str kssj 15:00:00--17:00:00
classroom str kscdmc XXX教学楼201
exam_form str ksxsmc 闭卷
exam_type str khxsmc 笔试

StudentInfo(学籍)

数据来自 welcome 页(data-userbh/data-userxm)+ edit.page 表单。

属性 类型 教务字段 示例
student_id str data-userbh 2021000000
name str data-userxm 张三
id_number str sfzh 440000200001010001
phone str dh 13800000000
email str email example@qq.com
home_address str jtdz XX省XX市...
exam_number str ksh 25440000000000
previous_school str lyzx XX中学
enrollment_date str rxrq 20240901
pinyin_name str py Zhang San
english_name str xsywxm Zhang San

Session 复用

client.save_session("cookie.cache")
client = Client.from_session("cookie.cache")   # 免重新登录

验证码处理

默认使用 ddddocr 自动识别。如需手动输入回退:

from wyu_jwxt import Client, ManualSolver

def my_callback(image_bytes):
    with open("captcha.jpg", "wb") as f:
        f.write(image_bytes)
    return input("请输入验证码: ").strip()

client = Client(manual_solver=ManualSolver(my_callback))

其他乘方学校兼容

from wyu_jwxt import Client, SchoolConfig

class MySchool(SchoolConfig):
    base_url = "https://jwxt.other.edu.cn"
    # 接口路径或加密方式不同时在此 override

client = Client(config=MySchool())

异常

异常 触发条件
LoginError 登录失败(密码错/验证码错/双因素触发)
CaptchaError 验证码获取或识别失败
SessionExpiredError 未登录时调用数据接口
RequestError 教务服务器不可达或超时
ChengfangError 基类,可统一捕获所有 SDK 异常

许可

MIT License

贡献

此 SDK 的接口协议全部逆向自五邑大学乘方教务系统实测。如果你所在学校也使用乘方教务,欢迎测试兼容性并提交 PR。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wyu_jwxt-0.1.2.tar.gz (20.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wyu_jwxt-0.1.2-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file wyu_jwxt-0.1.2.tar.gz.

File metadata

  • Download URL: wyu_jwxt-0.1.2.tar.gz
  • Upload date:
  • Size: 20.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for wyu_jwxt-0.1.2.tar.gz
Algorithm Hash digest
SHA256 48202d76fbe228921b2b91353ad1550e84e7ec939dad3d1db35099afb0120aeb
MD5 8db24f76878fc2d95a7d81b5da6c0333
BLAKE2b-256 187d2caec545498f98d03953e546ef5040c7d377387643375f01e323f60155f3

See more details on using hashes here.

File details

Details for the file wyu_jwxt-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: wyu_jwxt-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 16.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for wyu_jwxt-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 77946cb013b7ac373ec1ce74e7f2eee17baed305cc57f236f4810031616a5815
MD5 644664c10cdbc8b6ca626713badadb03
BLAKE2b-256 f85d31b3b7eaa7b8eb3cf1bea65837e960fe9cbdc7455d05c730afee319c0f10

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page