# Labali Wechat Download Article

> Browser-only automation skill to export a WeChat public account article into a local folder, including article.mhtml, article.md, and all embedded images.

- Skill: `kingson4wu/labali-wechat-download-article` (Agent Skill, multi-file: 9 files)
- Install (CLI): `npx skillmds@latest add kingson4wu/labali-wechat-download-article`
- Raw SKILL.md: https://api.skillmd.com/api/skills/kingson4wu/labali-wechat-download-article/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: Kingson4Wu (https://skillmd.com/u/kingson4wu)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/kingson4wu/labali-wechat-download-article

---


# labali-wechat-download-article

> **MANDATORY — load `references/plan.md` before any browser or extraction action begins.**

## ⚠️ NEVER WRITE YOUR OWN SCRIPT

**The download logic is fully implemented. Always invoke the existing script — do NOT write a new one.**

```bash
cd /Users/kingsonwu/programming/kingson4wu/labali-skills
npx tsx skills/private/labali-wechat-download-article/scripts/run.ts \
  --post_url "<url>" \
  --output_dir "$HOME/Downloads/wechat"
```

The sections below are **implementation documentation for the script itself**, not instructions for you to re-implement. If the script doesn't exist or can't run, report the error — never substitute with hand-written Playwright code.

## Required Constraints

- Use browser automation only (Playwright over CDP).
- Reuse authenticated Chrome session via CDP startup:
  `open -na "Google Chrome" --args --remote-debugging-port=9223 --user-data-dir="$HOME/.chrome-labali-no-proxy" --no-proxy-server`
- Extract article content from WeChat DOM: title, account name, author, publish time, content text, images.
- Images are lazy-loaded via `data-src` — always prefer `data-src` over `src`.
- Download only images from `mmbiz.qpic.cn` (skip avatars from `mmbiz.qlogo.cn`).
- Generate `article.md` with metadata and image references.
- Do not generate a manifest file.

## WeChat Article Structure

WeChat public account articles (`mp.weixin.qq.com/s/...`) use this DOM structure:

- **Title**: `#activity-name` or `.rich_media_title`
- **Account (WeChat Official Account)**: `#js_name` or `.account_nickname_inner`
- **Publish time**: `#publish_time` (format: `YYYY-MM-DD`)
- **Content**: `#js_content` — the main article body
- **Images**: `#js_content img[data-src]` — lazy-loaded content images

WeChat articles are mostly public pages. Login is only required for member-only or private content.

## Anti-Detection Principles

- If a WeChat tab is already open, reuse it — do not open a new tab or navigate away from other tabs.
- After `page.goto()`, wait 1.5–2.5 seconds (randomized) before extracting.
- Do not issue parallel HTTP requests for images — download sequentially with 200–500ms random delays.

## NEVER

- **Never write a custom Playwright/Node.js script** — the existing `scripts/run.ts` handles all extraction.
- **Never launch a new Chrome instance if CDP is already responding on port 9223.**
- **Never take over a non-WeChat browser tab** — find a WeChat tab to reuse, or open a new tab.
- **Never use `src` alone for WeChat image extraction** — WeChat lazy-loads via `data-src`; missing this yields 0 images.
- **Never retry automatically after a login wall** — pause and prompt the user to log in.
- Never report success if `article.md` was not generated.

## Success Criteria

A run is successful only when all conditions hold:

1. An article output folder is created under the specified local directory.
2. Folder naming format is `<download_date>-<sanitized_title>-<article_id>` (title omitted when empty).
3. `article.md` is generated with title, account, publish time, source URL, and image references.
4. All `mmbiz.qpic.cn` images from the article content are saved.
5. Partial image failure is acceptable — report failed URLs without throwing.

## Operational Mode

- Startup:
  - Check if CDP is responding: `curl -s http://localhost:9223/json/version`
  - If not → auto-launch Chrome (no user prompt needed), wait 3s, verify
  - If already running → reuse
- Tab management:
  - Find existing WeChat tab → reuse (navigate to article URL)
  - No WeChat tab → open new tab
- If login wall detected → prompt user to log in manually; wait for confirmation

## Resources

| When | Must load |
|------|-----------|
| Always — at skill invocation start | `references/plan.md` |
| Image extraction returns 0 images | Check `data-src` vs `src`; check if page scrolled enough for lazy load |

