feat: 添加超星学习通自动评教脚本及配置文件

实现超星学习通自动评教功能,支持账号密码登录和二维码登录
添加配置文件模板、依赖文件及gitignore配置
This commit is contained in:
EchoZenith
2026-05-04 23:07:19 +08:00
commit 4185141e7e
4 changed files with 742 additions and 0 deletions

34
data/config.example.py Normal file
View File

@@ -0,0 +1,34 @@
import json
import os
import time
CONFIG_FILE = os.path.join(os.path.dirname(__file__), "config.json")
USERNAME = "your_username" # 替换为你的学习通用户名
PASSWORD = "your_password" # 替换为你的学习通密码
QR_LOGIN = False # 设为 True 启用二维码登录(优先级高于账号密码)
def save_cookies(cookies_dict: dict):
data = {
"cookies": cookies_dict,
"saved_at": int(time.time()),
}
with open(CONFIG_FILE, "w", encoding="utf-8") as f:
json.dump(data, f, ensure_ascii=False, indent=2)
def load_cookies() -> dict | None:
if not os.path.exists(CONFIG_FILE):
return None
try:
with open(CONFIG_FILE, "r", encoding="utf-8") as f:
data = json.load(f)
return data.get("cookies")
except (json.JSONDecodeError, IOError):
return None
def clear_cookies():
if os.path.exists(CONFIG_FILE):
os.remove(CONFIG_FILE)