项目已重构为 Playwright 实现,不再依赖 Selenium 与 chromedriver。
目标页面: https://huiyi.enetedu.com/sxdjt2025
Windows 常见路径示例:
C:\Program Files\Tesseract-OCR\tesseract.exe
python -m pip install -r requirements.txt
python -m playwright install chromium
项目包含用于容器运行的 Dockerfile。镜像在构建时已完成以下工作以保证在无头 Linux 环境中可运行 Playwright 与 OCR:
playwright install --with-deps chromium 一并安装 Chromium 与其系统依赖(如 libnspr4、libnss3 等)。tesseract-ocr 系统包以支持 pytesseract。运行镜像示例(Linux 容器内请使用 Linux 风格路径):
docker run --rm docker.cnb.cool/${CNB_REPO_SLUG_LOWERCASE}:latest \
python ./open_huiyi.py -u <username> -p <password> --headless auto
注意事项:
python .\\open_huiyi.py)在 Linux 容器中会报错,请使用 ./open_huiyi.py 或完整 Linux 路径。--headless 参数(auto|true|false),默认 auto,会在无显示(无 DISPLAY/WAYLAND_DISPLAY)时自动切换为无头模式。python .\open_huiyi.py -u "你的账号" -p "你的密码"
可选参数:
--tesseract-cmd:指定 tesseract 可执行文件路径
--dump-profile / --dump:登录后前往个人中心并输出个人信息(通过日志打印,而非 print)
--screenshot:如果指定该参数并传入文件路径,脚本在结束前会导航/刷新到目标页面 https://huiyi.enetedu.com/LiveWacth/Index,等待渲染后保存完整页面截图到该路径(使用 Playwright 的 page.screenshot(..., full_page=True))。
截图文件会保存在脚本运行目录下(或你指定的相对/绝对路径)。如需只截取可视区域,请在代码中移除 full_page=True 或告诉我帮你改为可选参数。
例如:
python .\open_huiyi.py -u "your_user" -p "your_password" --tesseract-cmd "C:\Program Files\Tesseract-OCR\tesseract.exe"
也可通过环境变量指定:
$env:TESSERACT_CMD = "C:\Program Files\Tesseract-OCR\tesseract.exe"
python .\open_huiyi.py -u "your_user" -p "your_password"