Python/RPA framework for:
- Connecting to a local BitBrowser API
- Launching browser profiles in batches
- Opening the
公众账号助手extension - Scraping WeChat public account metrics
- Writing batch results back into a shared Tencent Docs sheet
- BitBrowser local API is reachable at
http://127.0.0.1:<port>. - Each BitBrowser profile has a non-empty profile/window name, and that name matches Tencent Docs column
A. - Tencent Docs is already opened and logged in inside a separate Chromium browser launched with remote debugging enabled.
- The browser toolbar contains a visible
公众账号助手extension icon, or you provide an image template for fallback clicking.
Selenium cannot attach to an arbitrary already-open browser window unless that browser was started with remote debugging.
Example:
chrome.exe --remote-debugging-port=9222 --user-data-dir=C:\temp\tencent-doc-profileThen open Tencent Docs manually in that browser and log in before running the script.
cd C:\Users\Administrator\bitbrowser_wechat_doc_rpa
python -m venv .venv
.venv\Scripts\Activate.ps1
pip install -r requirements.txtDry run:
python main.py --dry-runReal execution:
python main.py --write-back- BitBrowser API endpoint names vary. Adjust
src/bitbrowser_wechat_doc_rpa/config.pyif needed. - Tencent Docs DOM also varies. If row matching or write-back fails, calibrate
tencent_doc_writer.py. - Extension toolbar controls are outside normal web DOM. The script uses
pywinauto, then optionally image fallback. - If the separate Tencent Docs Chrome version is newer than your local
chromedriver, the script will fall back to direct CDP write-back on port9222.
Current recommended flow:
python .\script_1_build_daily_excel.py
python .\script_2_fill_daily_excel.pyQuick debug:
python .\script_1_build_daily_excel.py
python .\debug_3_profiles.pyThe standalone login-state extension flow is used to keep WeChat public-account sessions alive without changing the main flow or the local daily workbook.
Run all profiles:
python .\script_3_extend_login_state.py --mode allRun only non-publishing accounts:
python .\script_3_extend_login_state.py --mode non_publishingBehavior:
- At most
14BitBrowser windows are opened in one batch. --mode non_publishingreads the samedaily_YYYYMMDD.xlsxworkbook used by script 2 and skips accounts already covered there.- If the daily workbook does not exist,
--mode non_publishingfalls back toall. - Failed login-state probes are written to a separate workbook:
output\login_state_failures_YYYYMMDD_HHMMSS.xlsx
The desktop launcher keeps the Python source readable and editable, while providing an interactive Windows GUI entrypoint:
desktop_app.py: desktop launcherbuild_desktop_exe.bat: PyInstaller build script
Run from source:
python .\desktop_app.pyBuild the exe:
pip install pyinstaller
.\build_desktop_exe.batBuilt output:
dist\BitBrowserWechatDesktop.exe
Before code edits, create a targeted backup for the files you plan to change:
python .\pre_edit_backup.py --task "桌面端 UI 调整" desktop_app.py debug_3_profiles.pyBackup output is written under:
backups\code_edits\<timestamp>\
Each backup directory contains:
- original file copies
manifest.txtwith backup time, task, and file list