logo
0
0
WeChat Login
docs: 补充 --dump-profile / --dump 参数说明

会议学习自动化(Playwright 版)

项目已重构为 Playwright 实现,不再依赖 Selenium 与 chromedriver。

目标页面: https://huiyi.enetedu.com/sxdjt2025

功能

  • 打开可见浏览器并访问登录页
  • 自动填写用户名与密码(可选)
  • 识别验证码图片并填入输入框(pytesseract)
  • 登录后解析课程表
  • 筛选未完成课程并进入详情页
  • 按视频时长自动循环调用学习上报接口

环境要求

  • Python 3.10+
  • 已安装 Chrome/Chromium(Playwright 会启动 Chromium 内核)
  • 已安装 Tesseract OCR

Windows 常见路径示例:

C:\Program Files\Tesseract-OCR\tesseract.exe

安装

python -m pip install -r requirements.txt
python -m playwright install chromium

Docker 镜像(已提供)

项目包含用于容器运行的 Dockerfile。镜像在构建时已完成以下工作以保证在无头 Linux 环境中可运行 Playwright 与 OCR:

  • 使用 playwright install --with-deps chromium 一并安装 Chromium 与其系统依赖(如 libnspr4libnss3 等)。
  • 安装 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

注意事项:

  • 源脚本在 Windows 下的路径写法(例如 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"