wechat-article-fetch · Fetch WeChat Official Account Articles
Core Facts (Verified, Directly Executable)
- User-Agent is the Only Entry Barrier: Use a browser UA built into the scripts. Without a UA / curl / python-requests / MicroMessenger → all get 302 redirect.
- Article Body is Easily Accessible: Server-rendered, in
<div id="js_content">, raw GET suffices, no JS/Cookie/Login required. - Images Have No Hotlink Protection: Real URLs are in
data-src. - Discovery Layer: Original articles are not indexed by search engines; Sogou provides encrypted redirect chains. Clean-state pure HTTP can decode the signature into a direct link (window ≥1 hour, fetch promptly) ; ⚠️ Sending ~15–20 requests in 30 minutes triggers IP-level CAPTCHA (requires human intervention, browser cannot solve it) → serialize with low frequency, stop on trigger.
UA Example (for writing your own scripts): Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Usage (Scripts in same directory, zero dependencies, CLI + library dual mode, structured WeChatError)
python wechat_fetch.py "<url>" [--format md|json|text] [--out FILE] # Fetch article body
python wechat_discover.py "keyword" [--format table|json] # Search metadata (redirect chain decoding see channel status)
python batch_fetch.py urls.txt [--min-delay 3] [--max-delay 8] [--daily-limit 500] # Batch: rate limit / resume from breakpoint / halt on CAPTCHA
Channel Status (Tested 2026-08, to avoid dead ends)
| Channel | Status |
|---|---|
| Public article page raw fetch | ✅ Long-term stable (core of this skill) |
| Sogou search | ✅ Only recent metadata (clean state); redirect chain pure HTTP decode signature URL (window ≥1 hour, fetch promptly); ⚠️ ~15–20 requests in 30 minutes trigger IP CAPTCHA, requires human |
| Collection (album) page | ⚠️ Anonymous browsing possible, only articles within the collection |
| Official Account homepage history list | ❌ Anonymous access blocked: "Please open the link in WeChat client"; getmsg returns only latest ~10 articles |
| Official Account backend cross-account search | ❌ Defunct (WeChat closed on 2026-07-30, industry tools all down) |
Conclusion: Fetching layer stable; discovery layer ceiling = Sogou recent + collections (⚠️ dynamic rate limiting, use low frequency); full history has no compliant channel.
Workflow
- Have a link → GET (with browser UA) → Extract
#js_content→ Output. On failure, consult the diagnostic table, do not blindly retry. - Have only a keyword → Get metadata from Sogou; to get the article body, pure HTTP decode the redirect chain JS string to get the signed URL, then feed back into the fetch workflow (on failure / anti-crawl trigger, fall back to browser; or look for mirrored reprints, alert user that content may be deleted/edited). Do not attempt homepage history or backend search (dead/blocked).
Parsing (Only needed if writing your own regex; can skip when using the scripts directly)
Anchors: var msg_title / nickname / ct + #js_content. ⚠️ msg_title/nickname may have .html(false)/htmlDecode() wrappers — regex must match only the first quoted string after the equals sign, otherwise everything will be empty; images take data-src instead of src.
Failure Diagnosis (Do not retry blindly)
| Symptom | Cause | Action |
|---|---|---|
| 302 | Invalid UA | Switch to browser UA |
| 200 + Parameter error | Invalid link | Stop, verify the link |
| 302 → antispider | Sogou-side block (IP-level CAPTCHA, tested 2026-08-13, requires human) | Stop, do not bypass; retry at low frequency or wait for recovery (browser also blocked) |
| 302 → appmsgcaptcha | Abnormal link / CAPTCHA triggered | Stop, do not bypass |
| 200 + Page does not exist | UA detected as crawler | Switch to browser UA |
| 200 + Please open in WeChat client | Page requires login | Channel unavailable, switch to Sogou/collection |
| 200 + Deleted/Violation | Article has been processed | Skip, record reason |
Hard Constraints (Stop on violation)
- Do not touch login state: Personal WeChat / Official Account backend cookies, QR code login states are never used (account ban + contract breach).
- Do not bypass CAPTCHA: Triggering means full stop (bypassing technical measures violates Article 285 of Chinese Criminal Law).
- Do not scrape at scale:
robots.txtdisallows entire site; intended for small-scale personal research; serialize with second-level intervals, ≤500 articles per day. - No commercial use, no redistribution: Articles are protected by copyright; personal study/research falls under fair use (prerequisite: no redistribution, no commercial use, retain attribution).
- Discovery layer is subject to dynamic rate limits (tested 2026-08-13: ~15–20 requests per 30 minutes trigger IP CAPTCHA, not automatically lifted within hours): serialize at low frequency (recommended ≤10 requests per 30 minutes), stop entirely on trigger, wait for recovery, do not attempt to bypass.