Install
openclaw skills install @lililly123789/wechat-article-scraperBatch download WeChat (微信公众号) articles as Markdown files with embedded images. Triggers: 下载公众号文章, 批量抓取微信文章, 保存公众号内容, download wechat articles, scrape wechat posts, save articles with images.
openclaw skills install @lililly123789/wechat-article-scraperBatch download WeChat (微信公众号) articles from mp.weixin.qq.com URLs, saving each article as a properly formatted Markdown file with all content images downloaded locally and referenced via correct relative paths (images/artXX_imgXX.png).
mp.weixin.qq.com URLs and wants the full article content savedCollect all article URLs from the user. Create a text file with one URL per line:
https://mp.weixin.qq.com/s/xxxxx
https://mp.weixin.qq.com/s/yyyyy
https://mp.weixin.qq.com/s/zzzzz
Important: Only short-format URLs (mp.weixin.qq.com/s/xxxxx) work reliably. Long-format URLs (mp.weixin.qq.com/s?__biz=...&mid=...&sn=...) trigger WeChat's CAPTCHA and will fail. If the user provides long-format URLs, ask them to find the short-format versions instead.
The script requires requests, beautifulsoup4, and lxml. Install into the managed venv:
# Install packages (adjust path to match your environment)
<python-path> -m pip install requests beautifulsoup4 lxml
Execute the bundled script:
<python-path> <skill-dir>/scripts/download_wechat_articles.py urls.txt \
--output-dir ./articles-md \
--min-image-size 6000
Parameters:
urls_file: Text file with one WeChat URL per line (required)--output-dir: Output directory for markdown files (default: ./articles-md)--min-image-size: Minimum image size in bytes to keep (default: 6000). WeChat articles contain many small decorative icons (3-5KB) that are useless; real content images (charts, tables, screenshots) are typically 10KB+.--start-index: Starting article number for file naming (default: 1). Use when downloading additional batches to avoid filename conflicts.--retry: Number of retries on failure (default: 3). Uses exponential backoff.After download, check:
unknown-date)images/ prefixQuick check command:
# List articles and their image counts
for f in articles-md/*.md; do
count=$(grep -c '!\[图片\]' "$f")
echo "${count}张 $(basename "$f")"
done
# Check for any unknown-date files
ls articles-md/*unknown-date* 2>/dev/null
If any files have unknown-date, the date extraction failed (rare). Check the article content for date clues and rename manually.
articles-md/
├── 01-2026-08-03_Article_Title.md
├── 02-2026-08-01_Another_Title.md
├── ...
├── images/
│ ├── art01_img01.png (16KB - content chart)
│ ├── art01_img02.jpg (31KB - screenshot)
│ └── ...
└── manifest.json # metadata for all downloaded articles
The manifest.json contains:
{
"articles": [
{"idx": 1, "title": "...", "date": "2026-08-03", "filename": "...", "images": 2, "url": "..."}
],
"failed": [
{"idx": 5, "url": "...", "reason": "captcha"}
]
}
WeChat renders publish dates via JavaScript, so the <em id="publish_time"> element is empty in raw HTML. The script uses a multi-strategy approach to extract the date:
var ct = "unix_timestamp" — Primary method. WeChat embeds the article's creation time as a Unix timestamp in a JS variable. This is the most reliable source.oriCreateTime = "timestamp" — Fallback.create_time = "YYYY-MM-DD" — Fallback (sometimes present in page scripts).<em id="publish_time"> text — Rarely populated in raw HTML, but checked as a fallback.data-src attribute, not srcdata-src first, fall back to src<div id="js_content"> or <div class="rich_media_content"><h1 id="activity-name"><a id="js_name"><section>, <p>, <span> tags heavily — recursive traversal preserves reading orderWeChat articles embed many small UI elements as images:
Setting --min-image-size 6000 filters most of these. Real content images (charts, data tables, screenshots) are typically 10KB+.
The script includes a 2-second delay between article fetches to avoid being rate-limited by WeChat servers. Do not remove this delay.
Failed downloads automatically retry with exponential backoff (2s, 4s, 8s). The --retry parameter controls the number of attempts.
__biz= parameter trigger CAPTCHA. Only short URLs (/s/xxxxx) work.download_wechat_articles.py — Main batch download script. Accepts a URL list file and output directory, handles image downloading with size filtering, generates properly formatted Markdown with correct image paths. Supports retry logic and multi-strategy date extraction.requests — HTTP client for fetching articles and imagesbeautifulsoup4 — HTML parsinglxml — Fast XML/HTML parser backend for BeautifulSoup