
wechat-article-fetch
抓取微信公众号文章(mp.weixin.qq.com)到本地。当用户发来公众号链接要求"抓取""保存""存下来""归档""留痕""转成 Markdown"时使用。默认双产出:Markdown 整理版(供检索引用)+ HTML 原件保真归档(离线双击可读,供回溯核对)。默认 HTTP 直抓零依赖,失败自动切浏览器兜底。
- Installs
- 92
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/cat-xierluo/legal-skills --skill wechat-article-fetch- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads wechat-article-fetch automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
微信公众号文章抓取工具
概述
抓取微信公众号文章到本地,默认一次产出两份:
| 产物 | 用途 | 特点 |
|---|---|---|
| Markdown 整理版 | 检索、引用、下游加工 | 纯文本段落 + 图片本地化,自动过滤小装饰图 |
| HTML 原件 | 保真留痕、回溯核对 | 完整页面 + 全部图片本地化(不过滤),离线双击可读,原外链保留在 data-src 备查 |
为什么两份都要:公众号分享链接常带 tempkey 临时凭证,过期后打不开;Markdown 整理会丢排版和配图,日后无法回溯核对原文。原件保真,整理版好用,两者互补不互替。
抓取引擎:
- HTTP 直抓(默认主路线):微信文章是服务端渲染,正文与图片地址都在初始 HTML 里,直接请求即可。零依赖、速度快。
- Playwright 浏览器兜底(
--engine auto自动切换):HTTP 路线失败或页面需要 JS 渲染时启用。
使用方法
# 默认:双产出,保存到 skill 内 archive/<时间戳>_<标题>/
node scripts/fetch.js "https://mp.weixin.qq.com/s/xxxxx"
# 指定输出根目录(文章产物归入其下子目录)
node scripts/fetch.js "https://mp.weixin.qq.com/s/xxxxx" "./articles/"
# 兼容旧用法:直接指定 .md 文件路径(其余产物同目录平铺)
node scripts/fetch.js "https://mp.weixin.qq.com/s/xxxxx" "./articles/my-article.md"
# 只要 Markdown 整理版 / 只要 HTML 原件
node scripts/fetch.js "https://mp.weixin.qq.com/s/xxxxx" --mode markdown
node scripts/fetch.js "https://mp.weixin.qq.com/s/xxxxx" --mode archive
# 强制走浏览器(或只走 HTTP 不装 Playwright)
node scripts/fetch.js "https://mp.weixin.qq.com/s/xxxxx" --engine playwright
node scripts/fetch.js "https://mp.weixin.qq.com/s/xxxxx" --engine http
完整参数运行 node scripts/fetch.js --help 查看。
产物结构
archive/<YYYYMMDD_HHMMSS>_<文章标题>/
├── <文章标题>.md # 整理版(头部注明原文链接与 HTML 原件位置)
├── <文章标题>.html # 原件(src 已本地化,离线可读)
├── <文章标题>_assets/ # 整理版图片(智能过滤小装饰图)
└── <文章标题>_html_assets/ # 原件图片(全量保真,含小图标)
编程接口
import { fetchWechatArticle } from './scripts/fetch.js';
const report = await fetchWechatArticle("https://mp.weixin.qq.com/s/xxxxx", {
engine: 'auto', // 'auto' | 'http' | 'playwright'
mode: 'both', // 'both' | 'markdown' | 'archive'
outputPath: null, // 输出路径(可选)
retries: 3 // Playwright 路线重试次数
});
// report: { title, url, engine, md, archive: { htmlPath, images, missing, remoteLeft, failed } }
抓取后检查(必做,不要跳过)
看脚本输出:
- HTML 原件行首为
[OK ]即归档完整;[警告]时查看"缺失本地图"与"残留外链"两项 - 残留外链只剩微信官方空白占位
pic_blank.gif属正常,可忽略 - Markdown 的图片统计里"失败"应为 0,过滤数是装饰图属正常
- 页面报"该内容已被发布者删除""环境异常"等 → 链接失效,脚本会自动切换引擎重试;两条引擎都失败时不要再盲试链接
陷阱与要点
| 坑 | 处理 |
|---|---|
tempkey 链接会过期 | 收到就立刻抓,不要等"有空再存" |
图片真地址在 data-src 不在 src | src 多为 base64 占位;脚本已处理,手工排查时注意 |
URL 属性里是 & 不是 & | 解码后才能下载,否则 403;脚本已处理 |
图片域名不止 mmbiz.qpic.cn | 还有 mmecoa.qpic.cn 等,按 qpic.cn 后缀识别,别写死子域 |
wx_fmt 参数定扩展名 | 微信图 URL 无 .jpg 后缀,靠 ?wx_fmt=jpeg 推断,PNG 不会存成 jpg 名 |
| svg 小图标看着像 0KB | 原件目录里的几百字节装饰图标不是下载失败,别删(原件全量保真) |
| "环境异常"页 | 引擎自动切换重试;仍失败说明链接失效或需验证 |
下游加工建议
抓取完成后,如内容为法律法规、裁判文书等结构化法律文本,可在汇报时提示用户:如需进一步格式化整理,可指定相应的格式化技能(若环境中有)继续处理。是否调用、调用哪个技能由用户或上层流程决定——本技能不自动调用、不绑定任何下游技能。
注意事项
⚠️ 仅用于个人学习和研究,请遵守网站服务条款
⚠️ 频繁抓取可能被限流,建议控制请求频率
⚠️ 抓取内容版权归原作者所有
⚠️ Playwright 兜底路线首次使用会自动安装 chromium(npx playwright install chromium);HTTP 直抓路线零依赖
FAQ
What does the wechat-article-fetch skill do?
抓取微信公众号文章(mp.weixin.qq.com)到本地。当用户发来公众号链接要求"抓取""保存""存下来""归档""留痕""转成 Markdown"时使用。默认双产出:Markdown 整理版(供检索引用)+ HTML 原件保真归档(离线双击可读,供回溯核对)。默认 HTTP 直抓零依赖,失败自动切浏览器兜底。
How do I install wechat-article-fetch?
Run npx skills add https://github.com/cat-xierluo/legal-skills --skill wechat-article-fetch in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/wechat-article-fetch/ (personal) or .claude/skills/wechat-article-fetch/ (project).
Which AI agents can use wechat-article-fetch?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is wechat-article-fetch safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains wechat-article-fetch?
It is published by cat-xierluo in cat-xierluo/legal-skills. It has 92 recorded installs.
More from cat-xierluo/legal-skills
multi-search
cat-xierluo/legal-skills
智能多主题深度研究工具,支持任意材料输入,使用独立研究 Agent进行并行深度检索并生成系统化研究文档。本技能应在用户需要深度研究多个相关课题、进行系统性信息检索、整合多角度分析时使用。
douyin-batch-download
cat-xierluo/legal-skills
抖音视频批量下载工具 - 基于 F2 框架实现高效、增量的视频下载功能。支持单个/批量博主下载,自动 Cookie 管理,差量更新机制。本技能应在用户需要批量下载特定博主视频、服务器部署自动化下载、或定期更新视频库时使用。
litigation-analysis
cat-xierluo/legal-skills
判决书深度分析。本技能应在用户需要读懂一份判决书、拆解法院事实认定与裁判理由、解释判决主文或提炼文内疑点时使用。不要用于起诉状与证据初评、庭审笔录复盘、多材料综合研判或完整上诉再审决策;这些任务使用 legal-case-analysis。
md2word
cat-xierluo/legal-skills
Open the skill to read its SKILL.md instructions.
funasr-transcribe
cat-xierluo/legal-skills
Open the skill to read its SKILL.md instructions.
legal-proposal-generator
cat-xierluo/legal-skills
Open the skill to read its SKILL.md instructions.
Popular docs & writing skills
grill-with-docs
mattpocock/skills
A relentless interview to sharpen a plan or design, which also creates docs (ADR's and glossary) as we go.
lark-markdown
open.feishu.cn
飞书 Markdown:查看、创建、上传、编辑和比较飞书中的原生 Markdown 文件。当用户要操作飞书 Markdown 文件,或比较其远端版本及本地草稿时使用。纯本地 Markdown 文件操作不触发本 skill。不负责将 Markdown 导入为飞书在线文档,也不负责文件搜索、权限、评论、移动、删除等云空间管理操作。
writing-beats
mattpocock/skills
Writing, exploit; assemble raw material into a journey of beats, grounding each term before a beat leans on it.
writing-shape
mattpocock/skills
Writing, exploit: shape raw material into an article, paragraph by paragraph.
writing-fragments
mattpocock/skills
Writing, explore: mine raw fragments, no structure yet.
writing-for-agents
mattpocock/skills
Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md.