返回 Skill 列表
extension
分类: 数据与分析需要 API Key

公众号链接获取

Fetch historical article links from a WeChat Official Account by account name, fakeid, or gongzhonghao name, using the mp.weixin.qq.com backend cookie/token. Use when the user asks to crawl, export, collect, or list WeChat Official Account historical article URLs/links only, without fetching article body content.

person作者: user_2b46b0cfhubcommunity

Wx Gzh Link Crawler

Use this skill to export historical article links for one WeChat Official Account, also called a gongzhonghao or gzh. The bundled script only collects list metadata from mp.weixin.qq.com: title, digest, publish time, article URL, and cover URL. It does not open article pages and does not fetch article body content.

First-Run Checklist

Before running, make sure the user has:

  • A logged-in WeChat Official Account Platform session at https://mp.weixin.qq.com.
  • A valid token from the mp.weixin.qq.com URL.
  • A valid Cookie request header for mp.weixin.qq.com.
  • The target official account name, or its fakeid if already known.

If credentials are missing, tell the user to read references/credentials.md. Never ask the user to paste cookie/token into chat unless they explicitly accept that risk; prefer local config, environment variables, or command-line arguments typed on their machine.

Script

Use scripts/fetch_gzh_links.py.

Default behavior:

  • One WeChat backend API page returns up to 5 articles. This is the practical page size to explain to users.
  • One script run exports up to 100 articles by default.
  • Change the run limit with --max-articles N.
  • Use --max-articles 5 to fetch one page only.
  • Use --max-articles 20, --max-articles 50, --max-articles 100, etc. to fetch a specific maximum count.
  • Use --max-articles 0 to keep turning pages until the API stops returning more items or the session/rate limit blocks the run.
  • Use --since-date, --after-date, and --until-date for incremental or date-range exports.
  • Output format is CSV by default, encoded as utf-8-sig for Excel compatibility.
  • Optional JSON output is available with --format json.
  • The script exports link-list metadata only. It must not fetch article body content unless the skill is explicitly extended later.

CSV columns:

account_query, fakeid, title, digest, publish_time, create_time, link, cover_url

Crawl Amount Choices

Always tell the user which mode will be used before running:

  • One page test: --max-articles 5 --page-size 5; saves at most 5 links.
  • Default run: omit --max-articles; saves at most 100 links.
  • Specific count: --max-articles N; saves at most N links, turning pages in batches of 5.
  • Best-effort full history: --max-articles 0; keeps paging until no more list items are returned or WeChat rejects/limits the session.
  • Incremental update: use --after-date YYYY-MM-DD or --since-date YYYY-MM-DD; starts from the newest page and stops once articles are older than the lower date bound.
  • Date range: use --since-date YYYY-MM-DD --until-date YYYY-MM-DD; keeps only articles in that range and stops when older pages are no longer needed.

Do not promise true "all historical articles" as guaranteed. The mp.weixin.qq.com backend can stop, rate-limit, or hide older items depending on account/session state.

Incremental Update Guidance

Use date filtering for repeat crawls instead of re-fetching everything.

  • --since-date 2026-07-04 keeps articles published on or after 2026-07-04 00:00:00.
  • --after-date 2026-07-04 keeps articles published after 2026-07-04 23:59:59; this is the right choice for "after July 4".
  • --until-date 2026-07-11 keeps articles published on or before 2026-07-11 23:59:59.

Example: if the user fetched links on July 4, 2026 and comes back on July 11, 2026 asking for only new links after July 4, run:

python C:\Users\ASUS\.codex\skills\wx-gzh-link-crawler\scripts\fetch_gzh_links.py --account "account name" --after-date 2026-07-04 --max-articles 0

This still requests pages in 5-article batches because that is how the WeChat backend list works, but it does not need to save or continue through the full history. It stops when it reaches articles at or before the requested lower date bound.

Workflow

  1. If credentials are missing, guide the user through references/credentials.md.
  2. If the user has only an account name, run the script with --account.
  3. If the user already has fakeid, run the script with --fakeid to skip search.
  4. After export, tell the user how many links were saved and where the output file is.
  5. Tell the user the output format: CSV by default, or JSON when --format json is used.
  6. Reconfirm that no article body content was fetched.
  7. If the API returns ret=200003, ret=200013, or invalid session, tell the user the cookie/token expired and send them back to the credential refresh steps.

Commands

Create a local config template:

python C:\Users\ASUS\.codex\skills\wx-gzh-link-crawler\scripts\fetch_gzh_links.py --init-config

Fetch by official account name:

python C:\Users\ASUS\.codex\skills\wx-gzh-link-crawler\scripts\fetch_gzh_links.py --account "account name" --max-articles 100

Fetch one page only:

python C:\Users\ASUS\.codex\skills\wx-gzh-link-crawler\scripts\fetch_gzh_links.py --account "account name" --max-articles 5 --page-size 5

Fetch as much as the backend will return:

python C:\Users\ASUS\.codex\skills\wx-gzh-link-crawler\scripts\fetch_gzh_links.py --account "account name" --max-articles 0

Fetch only articles after a prior crawl date:

python C:\Users\ASUS\.codex\skills\wx-gzh-link-crawler\scripts\fetch_gzh_links.py --account "account name" --after-date 2026-07-04 --max-articles 0

Fetch a date range:

python C:\Users\ASUS\.codex\skills\wx-gzh-link-crawler\scripts\fetch_gzh_links.py --account "account name" --since-date 2026-07-04 --until-date 2026-07-11 --max-articles 0

Fetch by known fakeid:

python C:\Users\ASUS\.codex\skills\wx-gzh-link-crawler\scripts\fetch_gzh_links.py --fakeid "MzkxMjYzMzE2Mg==" --account "account label" --max-articles 100

Save JSON instead of CSV:

python C:\Users\ASUS\.codex\skills\wx-gzh-link-crawler\scripts\fetch_gzh_links.py --account "account name" --format json

User Guidance

When the user is ready to run it, explain these points in the user's language:

  1. Prepare the mp.weixin.qq.com cookie and token first; offer credential steps if they do not have them.
  2. Store credentials in the local config, or set WX_MP_COOKIE and WX_MP_TOKEN.
  3. Ask for the target WeChat Official Account name next.
  4. Ask how much to fetch: one page (5 links), a specified maximum count, default 100, or best-effort full history.
  5. For repeat crawls, ask whether the user wants new links after a previous date; prefer --after-date for "after that day".
  6. State that one API page returns up to 5 articles and the script turns pages automatically in batches of 5.
  7. State that the result is CSV by default and contains article links plus list metadata only, not body content.