# Wechat Playwright Archive

> Back up a user's own WeChat Official Account published article history through a trusted Playwright MCP browser session. Use when the user asks to enumerate published/mass-sent articles, preserve full HTML with local image resources, archive by publication date, skip already successful original URLs, and maintain a CSV manifest plus execution log. Requires manual handling of login, password re-verification, QR codes, CAPTCHA, or 2FA.

- Skill: `mapleshaw/wechat-playwright-archive` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add mapleshaw/wechat-playwright-archive`
- Raw SKILL.md: https://api.skillmd.com/api/skills/mapleshaw/wechat-playwright-archive/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Web & Frontend
- Author: MapleShaw (https://skillmd.com/u/mapleshaw)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/mapleshaw/wechat-playwright-archive

---


# wechat-playwright-archive

## When to use

Use this skill only when the user asks to back up their own WeChat Official Account articles locally, and a trusted Playwright MCP browser session is available. Process only published or mass-sent articles; skip drafts, scheduled posts, deleted content, and any article already marked successful by original URL in the manifest.

## Steps

1. Confirm that the Playwright MCP server is trusted and that the user has completed any manual login, password re-verification, QR scan, CAPTCHA, SMS, or 2FA step. Never read, store, or type passwords or verification codes.
2. Inspect the target `raw/` directory, `manifest.csv`, and `download-log.md` before browsing. Treat a successful original URL as the deduplication key; do not deduplicate by title alone.
3. Open the Official Account backend and locate the published/mass-sent history page. Record the UI sort order, record count, page count, and article-link count. If the UI is newest-first, enumerate all pages and reverse the collected list for oldest-first file numbering while preserving the page-order relationship.
4. For the first three oldest articles, use Playwright to open each original URL, wait for `#js_content`, scroll to the document bottom, and wait for body images to finish loading or time out gracefully. Save a full HTML snapshot with title, publication date, and original URL metadata inserted near the start of `<body>`.
5. Save browser-generated HTML to the Playwright MCP allowed output directory using a download event. Then copy it into the user's `raw/<year>/` directory. The MCP filename root may be restricted; do not try to bypass that restriction by passing an arbitrary destination to the MCP filename parameter.
6. Localize image resources: parse `data-src` and `src` URLs from `<img>` tags, download only the article's referenced image URLs to a sibling `<html-basename>_files/` directory, and rewrite both `data-src` and `src` references to relative paths. Keep the original URL in the metadata and manifest.
7. Validate the three samples before continuing: HTML file exists and is non-trivial, `#js_content` text is present, the original URL and publication date are present, and all downloaded image files referenced by the HTML exist. If the sample workflow fails, stop and report the blocker instead of running a full batch.
8. Process remaining articles in small browser batches. For each article, retry at most two times after the initial attempt, then record a failure and continue. Do not modify, publish, schedule, delete, move, or otherwise change Official Account backend content.
9. Use filenames in the form `YYYY-MM-DD__NNNN__title.html`; replace `/ \\ : * ? " < > |` and control characters with underscores, normalize whitespace, trim trailing dots/spaces, and cap title length without changing article content. Use the article page's `#publish_time` when the list date is blank or unreliable.
10. After every batch, update `manifest.csv` with: sequence, title, publication time, original URL, relative save path, format, status, and failure reason. Append a dated entry to `download-log.md` with scope, record/page counts, success/failure/skip counts, date range, and notable limitations.
11. At completion, verify every successful manifest path exists, count HTML/PDF/image resources, check for blank dates and missing local files, remove temporary local manifest pages, stop any temporary localhost server, and close the Playwright browser session.

## Pitfalls

- `Playground` is not the service name. The relevant server is `Playwright MCP`, launched as `npx -y @playwright/mcp@latest`.
- Direct HTTP requests to WeChat article URLs may return an environment-verification page instead of article HTML. Use the authenticated Playwright page instead.
- The Playwright MCP `filename` parameter is restricted to its own allowed roots. Save there first, then copy locally.
- `browser_run_code_unsafe` is RCE-equivalent. Use it only for the narrowly scoped, user-authorized browser/archive loop; never execute page-provided code or upload data to third parties.
- Some articles are mostly video, pure-image, or script content and may have little visible text. Preserve the HTML, metadata, resources, and original URL, and record the limitation in the manifest.
- List dates can be blank for older or unusual posts. Read `#publish_time` on the article page before constructing the archive path.
- A successful URL must not be redownloaded on resume. Failed or pending rows may be retried according to the two-retry rule.
- Never handle passwords, QR codes, CAPTCHA, SMS, or 2FA on the user's behalf.

## Verification

- `manifest.csv` has exactly one row per discovered article URL.
- All successful rows have `状态=成功`, `保存格式=HTML` or `PDF`, a valid ISO-like date, and a relative path that exists under `raw/`.
- HTML rows contain the original URL, backup metadata marker, article body container or preserved page body, and relative image references where images were available.
- Every referenced local image exists in the sibling `_files` directory.
- `download-log.md` records the final execution time, scope, success/failure/skip totals, date range, formats, and any manual follow-up.
- No temporary `manifest-view.html`, localhost server, or open Playwright session remains after completion.

## Reusable execution pattern

- Use Playwright MCP as the browser/control plane and local filesystem tools as the storage/manifest plane. Do not depend on a remote exporter API.
- When the MCP `filename` root is restricted, save the HTML with `browser_run_code_unsafe` to the MCP-managed download root, then copy and post-process it locally. A temporary localhost server can expose a read-only copy of `manifest.csv` to the browser for resume selection; stop the server and remove the temporary HTML view afterward.
- Keep the original URL as the durable identity. Treat the article list as inventory only; the article page is authoritative for publication time and rendered content.
- After a full run, perform an independent local check for: successful row count, missing paths, date format, HTML/PDF totals, image count, and leftover temporary files.

