Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WeChat Article Reader for Codex

一个面向 Codex 的微信公众号文章读取 Skill。输入公开的 mp.weixin.qq.com/s/... 链接,即可提取标题、作者、公众号、发布时间、正文、链接、表格和图片,并输出干净的 Markdown。

功能

  • 读取公开微信公众号文章并输出 Markdown
  • 保留标题层级、段落、强调、引用、列表、表格、链接、图片和小程序卡片
  • 可下载正文图片并改写为本地相对路径
  • 静态 HTTP 优先;被微信限制时可使用本地 CDP 代理,或交给 Codex 的 Browser/Chrome 读取
  • 识别验证页、登录页和失效页面,不把错误页当成文章
  • 将文章正文视为不可信输入,避免文章中的提示注入影响 Codex

安装到 Codex

可以直接让 Codex 安装:

请使用 $skill-installer 从 https://github.com/jmuguy/wechat-article-reader 安装这个 Skill。

也可以手动安装到个人 Skill 目录:

git clone https://github.com/jmuguy/wechat-article-reader.git \
  ~/.codex/skills/wechat-article-reader

python3 -m venv ~/.codex/skills/wechat-article-reader/.venv
~/.codex/skills/wechat-article-reader/.venv/bin/python -m pip install \
  -r ~/.codex/skills/wechat-article-reader/requirements.txt

安装后开启新的 Codex 会话,让 Skill discovery 重新加载。

使用

向 Codex 提供公众号链接和任务即可:

请读取并总结这篇微信公众号文章:https://mp.weixin.qq.com/s/...
请把这篇文章保存成 Markdown,并把正文图片下载到本地:https://mp.weixin.qq.com/s/...

Codex 会按照 SKILL.md 使用绝对路径调用脚本,因此不要求用户当前位于 Skill 目录。

命令行

在仓库根目录运行:

python3 scripts/read_wechat_article.py "https://mp.weixin.qq.com/s/..."
python3 scripts/read_wechat_article.py "<URL>" --output article.md
python3 scripts/read_wechat_article.py "<URL>" --output article.md --images-dir images

参数:

  • --timeout:请求超时秒数,默认 25
  • --no-cdp:禁用可选的 CDP 代理,只使用静态请求

抓取与浏览器兜底

脚本先使用轻量 HTTP 请求。收到 HTTP 403/429、微信验证页、登录页或只有动态数据而没有正文时,会尝试本地 CDP 代理:

export WECHAT_ARTICLE_CDP_PROXY="http://localhost:3456"

CDP 代理是可选能力,不是安装本 Skill 的前提。没有代理时脚本返回退出码 4,Codex 应改用 in-app Browser 或用户的 Chrome 会话读取页面。Skill 不会绕过验证码或账号限制。

退出码

含义
0 成功
1 读取或保存失败
2 缺少 Python 依赖
3 文章已保存,但部分图片下载失败
4 静态访问被限制,需要浏览器

测试与校验

python3 tests/test_extract.py
python3 ~/.codex/skills/.system/skill-creator/scripts/quick_validate.py .

使用边界

只处理无需登录即可访问的公开文章,不提供批量采集、验证码绕过或受限内容访问。请遵守微信平台规则、原作者版权和适用法律。

致谢与许可

抓取与 Markdown 抽取思路参考了 yxdsun/wechat-article-reader(MIT)。本项目在此基础上重写,并增加了静态失败识别和可选浏览器兜底。

本项目使用 MIT License

About

读取公开微信公众号文章为干净 Markdown 的 Claude Code / Codex Skill:静态优先 + CDP 浏览器兜底

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages