Community写作与编辑github.com

JJ-Yvain-Skills/wechat-article-fetch

公众号文章抓取/发现:零依赖无登录,UA 是唯一准入门槛(SKILL + 3 个 Python 脚本,MIT)

wechat-article-fetch 是什么?

wechat-article-fetch is a Claude Code agent skill that 公众号文章抓取/发现:零依赖无登录,UA 是唯一准入门槛(SKILL + 3 个 Python 脚本,MIT).

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add JJ-Yvain-Skills/wechat-article-fetch

Installed? Explore more 写作与编辑 skills: steipete/notion, langchain-ai/langchain, bytedance/podcast-generation · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

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)

ChannelStatus
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)

SymptomCauseAction
302Invalid UASwitch to browser UA
200 + Parameter errorInvalid linkStop, verify the link
302 → antispiderSogou-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 → appmsgcaptchaAbnormal link / CAPTCHA triggeredStop, do not bypass
200 + Page does not existUA detected as crawlerSwitch to browser UA
200 + Please open in WeChat clientPage requires loginChannel unavailable, switch to Sogou/collection
200 + Deleted/ViolationArticle has been processedSkip, record reason

Hard Constraints (Stop on violation)

  1. Do not touch login state: Personal WeChat / Official Account backend cookies, QR code login states are never used (account ban + contract breach).
  2. Do not bypass CAPTCHA: Triggering means full stop (bypassing technical measures violates Article 285 of Chinese Criminal Law).
  3. Do not scrape at scale: robots.txt disallows entire site; intended for small-scale personal research; serialize with second-level intervals, ≤500 articles per day.
  4. 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).
  5. 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.

相关技能