jackwener/wechat-article-to-markdown

GitHub: jackwener/wechat-article-to-markdown

一个将微信公众号文章抓取并转换为本地 Markdown 文件的命令行工具,支持图片下载、代码块处理和元数据提取。

Stars: 718 | Forks: 93

# wechat-article-to-markdown 抓取微信公众号文章并将其转换为简洁的 Markdown 格式。 [English](#features) | [中文](#功能特性) ## 功能特性 - 使用 Camoufox 进行反检测抓取 - 提取文章元数据(标题、公众号名称、发布时间、原文链接) - 将微信文章 HTML 转换为 Markdown - 将文章图片下载到本地 `images/` 并重写链接 - 处理微信 `code-snippet` 代码块并添加语言标记 ## 安装说明 ``` # 推荐:uv tool(快速、隔离) uv tool install wechat-article-to-markdown # 或者:pipx pipx install wechat-article-to-markdown ``` 或从源码安装: ``` git clone git@github.com:jackwener/wechat-article-to-markdown.git cd wechat-article-to-markdown uv sync ``` ## 使用方法 ``` # 已安装的 CLI wechat-article-to-markdown "https://mp.weixin.qq.com/s/xxxxxxxx" # 在 repo 中使用 uv 运行 uv run wechat-article-to-markdown "https://mp.weixin.qq.com/s/xxxxxxxx" # 向后兼容的 local entry uv run main.py "https://mp.weixin.qq.com/s/xxxxxxxx" ``` 输出结构: ``` output/ └── / ├── .md └── images/ ├── img_001.png ├── img_002.png └── ... ``` ## 测试 ``` # Unit tests(默认 CI 路径) uv run --with pytest pytest -q -m "not e2e" # 针对真实 WeChat 文章的 Live E2E WECHAT_E2E_URLS="https://mp.weixin.qq.com/s/Y7dyRC7CJ09miHWU6LBzBA,https://mp.weixin.qq.com/s/xxxxxxxx" \ uv run --with pytest pytest -q -m e2e -s ``` `e2e` 测试需要网络和浏览器运行环境,因此它们通过手动 GitHub Actions 工作流 `.github/workflows/e2e.yml` 运行。 ## 作为 AI Agent Skill 使用 本项目自带 [`SKILL.md`](./SKILL.md),以便 AI Agent 能够发现并使用此工具工作流。 ### [Skills CLI](https://github.com/vercel-labs/skills)(推荐) ``` npx skills add jackwener/wechat-article-to-markdown ``` | 参数 | 说明 | | --- | --- | | `-g` | 全局安装(用户级别,跨项目共享) | | `-a claude-code` | 指定特定的 Agent | | `-y` | 非交互模式 | ### 手动安装 ``` mkdir -p .agents/skills git clone git@github.com:jackwener/wechat-article-to-markdown.git \ .agents/skills/wechat-article-to-markdown ``` ``` # Claude Code user-level skills directory(全局) mkdir -p ~/.claude/skills/wechat-article-to-markdown curl -o ~/.claude/skills/wechat-article-to-markdown/SKILL.md \ https://raw.githubusercontent.com/jackwener/wechat-article-to-markdown/main/SKILL.md ``` 添加该文件后,请重启 Claude Code 以重新加载 skills。 ### ~~OpenClaw / ClawHub~~(已弃用) ## PyPI 发布 (GitHub Actions) 仓库地址:`jackwener/wechat-article-to-markdown` 工作流:`.github/workflows/release.yml` 环境:`pypi` `release.yml` 在 `v*` 标签上触发,运行单元测试 + 实时 e2e 测试,然后使用可信发布(`id-token: write`)发布到 PyPI。 对于发布 e2e 的目标,请设置仓库变量 `RELEASE_E2E_URLS`(以逗号分隔的文章 URL)。 如果未设置,工作流将回退到 `https://mp.weixin.qq.com/s/Y7dyRC7CJ09miHWU6LBzBA`。 ## 功能特性 - 使用 Camoufox 进行反检测抓取 - 提取标题、公众号名称、发布时间、原文链接 - 将微信公众号文章 HTML 转换为 Markdown - 下载图片到本地 `images/` 并自动替换链接 - 处理微信 `code-snippet` 代码块并保留语言标识 ## 安装说明 ``` # 推荐:uv tool uv tool install wechat-article-to-markdown # 或者:pipx pipx install wechat-article-to-markdown ``` ## 使用示例 ``` wechat-article-to-markdown "https://mp.weixin.qq.com/s/xxxxxxxx" ``` ## 作为 AI Agent Skill 使用 项目自带 [`SKILL.md`](./SKILL.md),可供支持 `.agents/skills/` 约定的 Agent 自动发现。 ### [Skills CLI](https://github.com/vercel-labs/skills)(推荐) ``` npx skills add jackwener/wechat-article-to-markdown ``` | 参数 | 说明 | | --- | --- | | `-g` | 全局安装(用户级别,跨项目共享) | | `-a claude-code` | 指定目标 Agent | | `-y` | 非交互模式 | ### 手动安装 ``` mkdir -p ~/.claude/skills/wechat-article-to-markdown curl -o ~/.claude/skills/wechat-article-to-markdown/SKILL.md \ https://raw.githubusercontent.com/jackwener/wechat-article-to-markdown/main/SKILL.md ``` ### ~~OpenClaw / ClawHub~~(已过时) ## License MIT
标签:BeEF, Blue Team, Markdown, Python, URL抓取, 反爬虫, 安全规则引擎, 微信公众号, 数据抓取, 无后门, 格式转换, 爬虫, 逆向工具