Skip to content

pzc163/wechat-publisher-bot

Repository files navigation

WeChat Article Publisher

一个用于将 Markdown 文章或网页内容整理后发布到微信公众号草稿箱的工具仓库。

它支持:

  • 从本地 .md 文件发布文章
  • 从网页 URL 抽取正文并发布
  • 自动生成微信公众号适配 HTML
  • 使用统一排版模板,例如 magazine-blue
  • 输出草稿 media_id,并支持提交发布与查询状态

适用场景

这个仓库适合以下用途:

  • 作为一个本地 skill 使用
  • 作为一个可复用的微信公众号排版与发布脚本
  • 作为自己文章生产流程的一部分

目录说明

快速开始

  1. 安装依赖
python scripts/publish_wechat.py --install
  1. 准备配置
  • 复制 config.example.jsonconfig.json
  • 如需本地保存发布元数据,复制 _meta.example.json_meta.json
  • 填写你自己的:
    • wechat.app_id
    • wechat.app_secret
    • wechat.author
  1. 先做本地预览
python scripts/publish_wechat.py '你的文章.md' --template magazine-blue --code-block-mode wechat-experimental --dry-run
  1. 发布到公众号草稿箱
python scripts/publish_wechat.py '你的文章.md' --template magazine-blue --code-block-mode wechat-experimental

模板

当前支持的模板:

  • standard
  • magazine-blue

说明:

  • magazine-blue 是当前推荐模板
  • 旧名称 viral 仍然兼容,但建议以后统一使用 magazine-blue

常用命令

发布 Markdown 文件:

python scripts/publish_wechat.py '文章.md' --template magazine-blue --code-block-mode wechat-experimental

只渲染预览,不调微信接口:

python scripts/publish_wechat.py '文章.md' --template magazine-blue --code-block-mode wechat-experimental --dry-run

抓取网页并发布:

python scripts/publish_wechat.py 'https://example.com/article' --template magazine-blue

安全说明

  • config.json 含有真实公众号密钥,不应提交到 GitHub
  • _meta.json 可能包含本地发布元数据,例如 ownerIdpublishedAt,也不建议提交到 GitHub
  • 仓库已通过 .gitignore 忽略:
    • config.json
    • _meta.json
    • .venv/
    • article/
    • image/
    • 本地预览 HTML
    • 生成封面和缓存文件

当前样式能力

magazine-blue 模板目前已经统一处理了这些元素:

  • 一级/二级标题模板
  • 正文段落
  • 引用块
  • 列表
  • 表格
  • 代码块
  • 强调文字
  • 分隔线
  • 文末来源说明和链接信息区

输出结果

脚本会输出 JSON,常见字段包括:

  • draft_media_id
  • publish_id
  • status
  • preview_html

备注

这个仓库会保留脚本、模板和说明文档;文章草稿、配图和本地发布元数据默认按本地素材处理,不建议继续提交到公开仓库。

About

No description, website, or topics provided.

Resources

Stars

5 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages