SuperAPI AI Directory

wechat-download

General & other

View repository

Updated 10-15 23:45

About this skill

WeChat official account article download

Through a locally deployed wechat-download-api service, batch download all historical articles (including full content) of any WeChat official account.

Trigger conditions

  • The user asks to download/crawl WeChat official account articles
  • The user asks to search for an official account and get its articles
  • The user says "download the articles of XX official account"
  • The user mentions wechat-download / 公众号下载 / 微信文章抓取

Architecture

本 skill (调用脚本)  →  wechat-download-api (本地 HTTP 服务 :8765)  →  微信公众平台 API
  • wechat-download-api: third-party open-source service, uses Chrome TLS fingerprint (curl_cffi) to simulate a browser, and calls the API through WeChat official platform backend credentials
  • This skill's script: encapsulates the API's search, list, and download functions, with adaptive rate limiting and resumable downloads

Usage

After the user installs this skill, they only need to say in the agent "download the official account articles of XXX". Except for QR code login, do not ask the user to manually deploy the underlying service; the agent should prioritize automatically running the scripts in this directory to complete environment preparation.

1. Start the service

Run from the skill directory:

cd ~/.claude/skills/wechat-download
bash scripts/start_wechat_api.sh
# 默认端口 8765,可指定: bash scripts/start_wechat_api.sh 9876

The script will automatically discover ./wechat-download-api、../wechat-download-api, and also supports locating it through the WECHAT_API_REPO environment variable. If it cannot be found, it will automatically clone wechat-download-api to the current skill directory and install the underlying service dependencies.

Port note: this skill uses 8765 by default instead of upstream's 5000, because on macOS 5000 is often occupied by system services. If you started the service with upstream's start.sh (port 5000), please add before the command WECHAT_API_URL=http://localhost:5000。

The script will automatically:

  • Find or download the wechat-download-api repository
  • Create .env(if it does not exist)
  • Install missing Python dependencies
  • Start the service in the background

2. QR code login

Prerequisite: the user needs to have a WeChat official account (subscription account/service account are both fine).

  1. Open in a browser http://localhost:8765/login.html
  2. Scan the QR code with the WeChat of the official account administrator
  3. After successful login, the credentials are automatically saved to .env, valid for about 4 days

If the user does not have an official account, see "Alternative solution" below.


Operation flow

Step 1: Check/start the service

If the service has not been started yet, run first:

bash scripts/start_wechat_api.sh

Then check the service status:

python3 scripts/download_wechat.py status

Step 2: Check login

curl -s http://localhost:8765/api/admin/status

If isExpired: true → scan the QR code again to log in.

Step 3: Search for the official account

python3 scripts/download_wechat.py search "公众号名称"

Get from the output fakeid。

Step 4: Download articles

python3 scripts/download_wechat.py download "fakeid" 200 ./output_dir

Features:

  • Automatically paginate to get the full article list
  • Download the full content article by article, save as .txt files
  • Resumable downloads: already downloaded files are automatically skipped
  • Adaptive rate limiting: automatically waits when Rate limited is detected
  • Failure records are saved to failures.json

Other commands

python3 scripts/download_wechat.py list "fakeid" 0 50     # 查看文章列表
python3 scripts/download_wechat.py rss "fakeid"            # 获取 RSS 地址

Common errors and solutions

Error 1: Port is occupied

ERROR: [Errno 48] address already in use

Solution: switch to another port:bash scripts/start_wechat_api.sh 9876

Error 2: Article URL field name (critical)

url = a.get("url", "")   # ❌ 错误!
url = a.get("link", "")  # ✓ 正确

The article list returned by the API uses the link field, not url。

Error 3: Rate Limited

Rate limited: 请求过于频繁,请X秒后重试

Solution: The script has built-in adaptive backoff. If it is still triggered frequently, increase MIN_DELAY(default 3.2 seconds).

Error 4: WeChat security verification triggered

触发微信安全验证。

Solution:

  • Reduce request frequency
  • Open the prompted article URL in a browser to complete the human verification
  • Wait 30 minutes and retry
  • If triggered frequently, configure .env in PROXY_URLS(SOCKS5 proxy pool)

Error 5: Unable to get article content

无法获取文章内容。可能原因:文章被删除、访问受限或需要验证。

Cause: The article has been deleted / is an advertisement / is an image share / WeChat risk control. Just skip it; this usually accounts for 30-50%.

Error 6: Login expired

Cause: WeChat credentials are valid for about 4 days.

Solution: Revisit http://localhost:8765/login.html to scan the QR code.

Error 7: curl_cffi compilation failed

ModuleNotFoundError: No module named 'curl_cffi'

Solution: A working C compiler is required. macOS requires installing Xcode CLT (xcode-select --install), Linux requires build-essential and libcurl4-openssl-dev. Precompiled wheels on PyPI cover mainstream platforms.


Alternative: Download without an official account

If the user does not have a WeChat official account and cannot log in, the following methods can be used:

  1. Search engine reverse lookup: Search "公众号名" mp.weixin.qq.com/s to get the article link, and directly visit mp.weixin.qq.com to extract the content in #js_content content in
  2. Reposting platforms: Search for reposted articles on platforms such as guancha.cn (Guancha), 36kr, Sina Finance, etc.
  3. Mirror sites: Platforms such as jintiankansha.me have article lists (but usually require VIP to view the full text)

Reference

  • wechat-download-api — underlying API service, AGPL 3.0
  • Article URL format description:https://mp.weixin.qq.com/s/{short_id} or a complete link with __biz/mid/idx/sn parameters