← 返回
未分类 Key

Elective

PKU Course Selection (选课网) CLI tool built in Rust. Use this skill when working on the elective crate, debugging elective commands, adding features, or when t...
PKU选课网 CLI 工具,使用 Rust 编写。适用于处理 elective crate、调试选课命令、添加功能或其他相关场景。
wjsoj
未分类 clawhub v1.1.0 1 版本 100000 Key: 需要
★ 0
Stars
📥 395
下载
💾 0
安装
1
版本
#cli#elective#latest#pku#rust

概述

Elective - 北大选课网 CLI

A CLI client for PKU's course selection system with auto-enrollment automation.

Architecture

  • Crate location: crates/elective/
  • Auth flow: IAAA SSO (app_id="elective") → elective SSO endpoint callback
  • API: HTML scraping + CAPTCHA handling (base64 image recognition)
  • Automation: Polling loop for auto-enrollment with configurable interval

Key Source Files

  • src/main.rs — Clap CLI with subcommands
  • src/commands.rs — Command implementations including auto-enroll loop
  • src/api.rs — HTML scraping, CAPTCHA image extraction
  • src/display.rs — Terminal output formatting
  • src/client.rs — reqwest client builders

CLI Commands

CommandAliasFunction
--------------------------
loginIAAA login (supports --dual for dual-degree students)
logout / statusSession management
showView current course selections
listlsBrowse available courses for add/drop
setAdd a course to auto-enroll target list
unsetRemove from auto-enroll targets
config-captchaConfigure CAPTCHA solver backend
launchStart auto-enrollment polling loop
otpTOTP 2FA management

CAPTCHA Backends

The config-captcha command supports multiple recognition backends:

  • manual — Display CAPTCHA image, user inputs answer
  • utool — UTool OCR service
  • ttshitu — TTShiTu recognition API
  • yunma — Yunma recognition API

Auto-Login for AI Agents

# Check session status
info-auth check

# Auto-login (reads credentials from OS keyring, no password needed)
elective login -p                  # single degree
elective login -p --dual major     # dual degree - major
elective login -p --dual minor     # dual degree - minor

Note: Dual-degree students MUST specify --dual major or --dual minor, otherwise login will fail with an error.

Development Notes

  • Auto-enrollment loop: configurable check interval (default 15s), polls for open slots
  • Dual-degree students use --dual flag at login for separate session
  • CAPTCHA images are base64-encoded, decoded and sent to recognition backend
  • All user-facing strings in Chinese
  • Error handling: anyhow::Result with .context("中文描述")
  • Session persisted to ~/.config/info/elective/
  • Credentials resolved via info_common::credential (keyring → env → interactive)

版本历史

共 1 个版本

  • v1.1.0 当前
    2026-05-03 09:10 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

PKU Info Spider

wjsoj
微信公众号文章爬虫 CLI 工具,使用 Rust 编写。适用于 info‑spider crate 的开发、调试爬虫命令等场景。
★ 0 📥 446

PKU Campus Card

wjsoj
PKU校园卡 CLI 工具,使用 Rust 编写。适用于处理 campuscard 工具库、调试校园卡命令、添加功能等场景。
★ 0 📥 438

PKU Info Auth

wjsoj
PKU 统一凭据管理 CLI(统一凭据管理)。当用户或 AI Agent 需要对 PKU服务进行身份验证或管理已存储的凭据时使用此技能。
★ 0 📥 431