# Send WeChat Work Doc Fetcher to your agent
Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.
## Fast path
- Download the package from Yavira.
- Extract it into a folder your agent can access.
- Paste one of the prompts below and point your agent at the extracted folder.
## Suggested prompts
### New install

```text
I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Then review README.md for any prerequisites, environment setup, or post-install checks. Tell me what you changed and call out any manual steps you could not complete.
```
### Upgrade existing

```text
I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Then review README.md for any prerequisites, environment setup, or post-install checks. Summarize what changed and any follow-up checks I should run.
```
## Machine-readable fields
```json
{
  "schemaVersion": "1.0",
  "item": {
    "slug": "wecom-doc-fetcher",
    "name": "WeChat Work Doc Fetcher",
    "source": "tencent",
    "type": "skill",
    "category": "效率提升",
    "sourceUrl": "https://clawhub.ai/mouzhi/wecom-doc-fetcher",
    "canonicalUrl": "https://clawhub.ai/mouzhi/wecom-doc-fetcher",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadUrl": "/downloads/wecom-doc-fetcher",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=wecom-doc-fetcher",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "packageFormat": "ZIP package",
    "primaryDoc": "SKILL.md",
    "includedAssets": [
      "README.md",
      "SKILL.md",
      "wx_doc_fetch.py"
    ],
    "downloadMode": "redirect",
    "sourceHealth": {
      "source": "tencent",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-04-30T16:55:25.780Z",
      "expiresAt": "2026-05-07T16:55:25.780Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=network",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=network",
        "contentDisposition": "attachment; filename=\"network-1.0.0.zip\"",
        "redirectLocation": null,
        "bodySnippet": null
      },
      "scope": "source",
      "summary": "Source download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this source.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/wecom-doc-fetcher"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    }
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/wecom-doc-fetcher",
    "downloadUrl": "https://openagent3.xyz/downloads/wecom-doc-fetcher",
    "agentUrl": "https://openagent3.xyz/skills/wecom-doc-fetcher/agent",
    "manifestUrl": "https://openagent3.xyz/skills/wecom-doc-fetcher/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/wecom-doc-fetcher/agent.md"
  }
}
```
## Documentation

### wecom-doc-fetcher

Use this skill when the user wants to save any page from the WeChat Work (企业微信) developer documentation site (developer.work.weixin.qq.com/document/path/*) as a clean Markdown file in their Obsidian vault.

### Files in this skill

wecom-doc-fetcher/
├── SKILL.md          # this file
└── wx_doc_fetch.py   # the fetch & convert script

### Setup (one-time)

Run these once before using the skill:

pip install requests playwright
playwright install chromium

playwright install chromium downloads a ~150 MB headless Chromium binary. This is required for automatic doc_id detection.

Python 3.8+ is required.

### Usage

Place wx_doc_fetch.py anywhere convenient (e.g. your vault's scripts folder), then run:

# Basic: auto-detect doc_id, print to stdout
python wx_doc_fetch.py <URL>

# Save to file
python wx_doc_fetch.py <URL> output.md

# Skip Playwright, supply doc_id manually
python wx_doc_fetch.py <URL> output.md --doc-id <integer>

# Override cookies at runtime
python wx_doc_fetch.py <URL> output.md --cookies "wwapidoc.sid=xxx; ..."

### Example

python wx_doc_fetch.py https://developer.work.weixin.qq.com/document/path/94677 发送消息.md
# [info] path_id=94677  doc_id=31152
# [done] 已写入：发送消息.md

### How It Works

The WeChat Work docs site is a Vue SPA — the visible content is not in the initial HTML. It is loaded at runtime via a private POST API:

POST https://developer.work.weixin.qq.com/docFetch/fetchCnt?lang=zh_CN&ajax=1&f=json
Body: doc_id=<integer>   (application/x-www-form-urlencoded)

The response includes data.content_md — the page content as a Markdown string. The script fetches this field, cleans it, and writes the result.

### Why not WebFetch / defuddle?

The page renders client-side. WebFetch and defuddle only see the pre-JS HTML skeleton — no content. Scraping innerText via browser tools works but produces a very large accessibility tree with poor formatting. The content_md API field is the cleanest, most token-efficient source.

### URL path ID ≠ doc_id

The number in the browser URL (e.g. 94677) is a routing slug — not the doc_id the API needs. The actual doc_id (e.g. 31152) is determined at runtime by loading the page with Playwright and intercepting the fetchCnt XHR request.

### Manual doc_id Fallback

If Playwright is unavailable or times out:

Open the target URL in Chrome
DevTools → Network tab → filter by fetchCnt
Click the request → Payload tab
Read the doc_id value
Pass it with --doc-id:

python wx_doc_fetch.py https://developer.work.weixin.qq.com/document/path/94677 发送消息.md --doc-id 31152

### Cookie Configuration

The fetchCnt API requires an authenticated session. Playwright's headless browser obtains session cookies automatically when loading the page — no manual cookie setup needed for normal use.

If you see errCode: -30001 in the output, the session is rejected. Fix:

Open the site in Chrome while logged in
DevTools → Network → any fetchCnt request → Copy as cURL
Find the -b '...' cookie string in the copied command
Either paste it into COOKIES_RAW at the top of wx_doc_fetch.py, or pass it via --cookies "..."

Key cookies and their lifetimes:

CookiePurposeLifetimewwapidoc.sidSession identifier~24 hourswwapidoc.token_wtJWT auth token~30 minutes

### API Reference

ItemDetailEndpointPOST /docFetch/fetchCnt?lang=zh_CN&ajax=1&f=json&random=<rand>Bodydoc_id=<integer> (form-urlencoded)AuthSession cookiesKey response fielddata.content_mdOther response fieldsdata.content_html, data.content_html_v2, data.content_txt, data.title, data.time

### content_md Cleaning Rules

The content_md field is mostly valid CommonMark but has site-specific issues. The clean_md() function in wx_doc_fetch.py handles all of them:

#ProblemRaw exampleAfter cleaning1[TOC] marker at top[TOC]\\n# 概述# 概述2Heading missing space after ###接口定义## 接口定义3Internal numeric anchor links[接收事件](#12977)接收事件3Anchors with sub-path[开启API](#31106/如何开启API)开启API4HTML line breaks inside table cells说明</br>补充说明 补充5<b> bold tags<b>注意</b>**注意**6<code> inline tags<code>open_kfid</code>\`open_kfid\`7<font> color tags<font color="red">警告</font>警告8!!#rrggbb text!! site-specific highlight!!#ff0000 重要!!重要9Leading spaces before table rows··| 参数 || 参数 |10No blank line before table (Obsidian won't render)文字\\n| col |文字\\n\\n| col |11Excess blank lines3+ \\n in a row2 \\n max

### Rule 10 — critical regex note

The blank-line-before-table rule must match on lines that don't start with |, not just on the trailing character of the previous line:

# CORRECT — matches on start of line, avoids breaking table rows apart
re.sub(r"^([^|\\n][^\\n]*)\\n(\\|)", r"\\1\\n\\n\\2", content, flags=re.MULTILINE)

# WRONG — table rows end with "| " (trailing space), so last char is space,
#          causing blank lines to be inserted between every table row
re.sub(r"([^\\n])\\n(\\|)", r"\\1\\n\\n\\2", content)
## Trust
- Source: tencent
- Verification: Indexed source record
- Publisher: mouzhi
- Version: 1.0.0
## Source health
- Status: healthy
- Source download looks usable.
- Yavira can redirect you to the upstream package for this source.
- Health scope: source
- Reason: direct_download_ok
- Checked at: 2026-04-30T16:55:25.780Z
- Expires at: 2026-05-07T16:55:25.780Z
- Recommended action: Download for OpenClaw
## Links
- [Detail page](https://openagent3.xyz/skills/wecom-doc-fetcher)
- [Send to Agent page](https://openagent3.xyz/skills/wecom-doc-fetcher/agent)
- [JSON manifest](https://openagent3.xyz/skills/wecom-doc-fetcher/agent.json)
- [Markdown brief](https://openagent3.xyz/skills/wecom-doc-fetcher/agent.md)
- [Download page](https://openagent3.xyz/downloads/wecom-doc-fetcher)