Communitygithub.com

bzd6661/wechat-article-for-ai

Convert WeChat Official Account articles to clean Markdown files with locally downloaded images.

What is wechat-article-for-ai?

This AI agent skill converts WeChat Official Account (微信公众号) articles into clean, AI-friendly Markdown files. It automatically downloads images locally, preserves code blocks with language detection, and strips WeChat UI noise for a distraction-free reading experience. The tool supports two interfaces: a command-line interface (CLI) for manual and batch conversion, and an MCP (Model Context Protocol) server for seamless integration with AI agents like Claude Code, Cursor, or Codex. The MCP server exposes two tools—`convert_article` and `batch_convert`—that accept article URLs, output directory, and options like image downloading. It uses a Camoufox headless browser to evade WeChat's anti-bot measures, though rate-limiting may still occur. This skill is essential for developers and AI agents who need to ingest WeChat article content into workflows, RAG systems, or datasets without formatting noise.

Works with✓Claude Code~Codex CLI~Cursor
npx skills add bzd6661/wechat-article-for-ai

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

WeChat Article to Markdown Converter

What this tool does

Converts WeChat public account articles into clean Markdown files with:

  • YAML frontmatter (title, author, date, source URL)
  • Locally downloaded images
  • Preserved code blocks with language detection
  • Audio/video reference extraction
  • Clean formatting (no WeChat UI noise)

Prerequisites

  • Python 3.10+
  • Install dependencies: pip install -r requirements.txt
  • Camoufox browser will be auto-downloaded on first run

Usage

CLI (single article)

python main.py "https://mp.weixin.qq.com/s/ARTICLE_ID"

CLI (batch from file)

python main.py -f urls.txt -o ./output -v

CLI Options

FlagDescription
-f FILEText file with URLs (one per line)
-o DIROutput directory (default: ./output)
-c NImage download concurrency (default: 5)
--no-imagesSkip image download, keep remote URLs
--no-headlessShow browser (for solving CAPTCHAs)
--forceOverwrite existing output
--no-frontmatterUse blockquote metadata instead of YAML
-vVerbose/debug logging

MCP Server

Run as an MCP server for AI tool integration:

python mcp_server.py

Exposes two tools:

  • convert_article(url, output_dir, download_images, concurrency, use_frontmatter) — Convert a single article
  • batch_convert(urls, output_dir, download_images, concurrency) — Convert multiple articles

MCP Configuration (for claude_desktop_config.json or similar)

{
  "mcpServers": {
    "wechat-to-md": {
      "command": "python",
      "args": ["mcp_server.py"],
      "cwd": "<path-to-this-project>"
    }
  }
}

Output Structure

output/
  <article-title>/
    <article-title>.md    # Markdown file with YAML frontmatter
    images/
      img_001.png
      img_002.jpg
      ...

Common Issues

  • CAPTCHA/verification page: Run with --no-headless to manually solve the CAPTCHA in the browser window, then retry.
  • Empty content: WeChat may rate-limit requests. Wait a few minutes and try again.
  • Image download failures: Failed images keep their remote URLs in the markdown. Re-run with --force to retry.

Limitations

  • Only supports articles from mp.weixin.qq.com
  • Requires a working internet connection and the ability to run a headless browser
  • WeChat may block automated access; Camoufox helps evade detection but is not guaranteed

Related Skills