WeChat Article Fetcher
Fetches articles from WeChat Official Accounts (微信公众号).
All scripts are in ${CLAUDE_SKILL_DIR}/scripts/. Run commands from that directory.
Setup (first time on a new machine)
pip install requests PyYAML beautifulsoup4 lxml playwright
python -m playwright install firefox
Token Auto-Login
search and list commands automatically check the token. If expired or missing, they trigger QR code login — no manual check/login needed.
When auto-login triggers:
- QR code image is saved and opened (Windows) automatically
- Tell the user: "请用微信扫描二维码登录公众平台"
- Wait for the command to complete (up to 5 minutes)
- Login succeeds → original command proceeds automatically
- Login fails → tell user "扫码登录失败,请重试" and suggest running the command again
Commands
搜索公众号
cd "${CLAUDE_SKILL_DIR}/scripts" && python __main__.py search "ACCOUNT_NAME" --limit 10
按名称搜索公众号,返回 fakeid、名称、别名。fakeid 用于获取文章列表。
When search returns multiple accounts, use AskUserQuestion to let the user pick which account to use. Present each account as an option with nickname (and alias if available) as the label, and fakeid as the value. Then use the selected fakeid for the subsequent list command.
获取文章列表
cd "${CLAUDE_SKILL_DIR}/scripts" && python __main__.py list "FAKEID" --name "ACCOUNT_NAME" --pages 2
分页获取公众号历史文章,每页约5篇。返回标题、链接、封面、摘要、时间戳。
获取文章全文
cd "${CLAUDE_SKILL_DIR}/scripts" && python __main__.py fetch "https://mp.weixin.qq.com/s/ARTICLE_ID"
提取文章完整内容,返回标题、作者、描述、正文(HTML)、发布时间、公众号信息。无需 token,直接打开文章 URL。
手动登录
cd "${CLAUDE_SKILL_DIR}/scripts" && python __main__.py login
手动触发扫码登录,用于 token 失效时重新获取。
检查 Token
cd "${CLAUDE_SKILL_DIR}/scripts" && python __main__.py check-token
检查当前 token 是否有效,过期时需重新登录。
Error Handling
- Auto-login succeeds → original command proceeds, no extra action
- Auto-login fails → tell user to try the command again
searchreturnsRATE_LIMITED→ wait 30-60s, retryfetchreturnsENV_ERROR→ IP blocked, wait and retryfetchreturnsDELETED→ article removed by authorfetchreturnsFETCH_ERROR→ may retry once
Notes
- Add 3-10 second delays between API requests
fetchtakes 10-30s per article (headless Playwright/Firefox)- All commands output JSON to stdout
contentfromfetchis HTML- Start with
--pages 1for article lists