wx-search: Search & Read WeChat Official Account Articles
wx-search-cli searches WeChat official account (公众号) articles through Sogou WeChat search and extracts article body text. Output is JSON (search) or plain text (content) on stdout; all failures exit 1 with the message on stderr.
Run it with npx wx-search-cli or bunx wx-search-cli (no install needed), or plain wx-search-cli if globally installed.
Typical workflow
Search for articles by keyword:
npx wx-search-cli search "人工智能"Output is a JSON array; each item has:
title— article titlelink— Sogou redirect URL (use as--refererwhen fetching content)real_url— resolvedmp.weixin.qq.comURL (empty string""if resolution failed, usually due to rate limiting)publish_time— ISO 8601 timestamppage— result page number, as a string
Read an article's body text, passing
real_urlas the argument andlinkas--referer:npx wx-search-cli content "<real_url>" --referer "<link>"
Commands
| Command | Purpose |
|---|---|
search <query> [--page <n>] |
One page of results (~10 items) as JSON. --page defaults to 1. |
search-all <query> [--max-pages <n>] |
Auto-paginate (1s delay between pages), stop on empty page or --max-pages (default 10). |
content <real_url> [--referer <url>] |
Print article body as plain text. |
skill |
Print this skill document. |
Important tips
- Keep request volume low. Heavy usage triggers Sogou's captcha; the symptom is
real_urlcoming back as""or the search command erroring with an anti-spider message. When that happens, back off and retry later — don't hammer the endpoint. - Prefer
searchoversearch-allunless the user genuinely needs many results; fewer requests means less captcha risk. - Always pass
--refererwhen fetching content if you have thelinkfield — it noticeably improves the success rate against WeChat's anti-scraping checks. - Search queries in Chinese generally return better results than English for 公众号 content.
- Nonzero exit code means failure; the reason is on stderr. Don't parse stdout on failure.