Skip to content

About

公众号转 RSS,不用扫码:把微信公众号变成 RSS / Atom 订阅源,GitHub Actions 定时更新,GitHub Pages 发布。Turn WeChat Official Accounts into RSS feeds, no QR login.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

wechat-rss:公众号转 RSS,不用扫码登录

English: turn WeChat Official Accounts into RSS / Atom feeds on GitHub Pages, no QR login.

把想看的微信公众号写进一个文本文件,GitHub Actions 每天定时取它们的最新文章,生成 RSS 2.0 和 Atom 订阅源, 放在你自己的 GitHub Pages 上。之后用任何 RSS 阅读器、Notion、飞书订阅都行。数据来自 okdata 社媒数据 API,按次付费。

  • 不用扫码、不用微信号、不用 Cookie,也不用自己维护服务器
  • 每个公众号一个订阅源,另外还有一个合集 all.xml
  • 文章会累积:每个源保留最近 50 篇(可调),旧文章滑出第一页后也还在
  • 可选取全文(默认只有标题和链接,全文每篇多一次调用)
  • 一个 Python 文件加一个小模块,只用标准库,Python 3.9 以上

五步用起来

  1. Fork 这个仓库。

  2. 拿 key、存成 secret:在 okdata 注册(注册送试用额度), 复制 API key。在你 fork 的仓库里打开 Settings → Secrets and variables → Actions → New repository secret, 名字填 OKDATA_API_KEY,值填 key。

  3. 改公众号列表:编辑 accounts.txt,一行一个:

    # 知道原始 ID(gh_ 开头)就写上,省掉搜索费,也不会认错号
    人民日报 = gh_363b924965e9
    # 只写名字也行:第一次会按名字搜一次,搜到的 ID 记在 state.json,之后不再搜
    某某公众号
    

    提交以后会自动跑一次。也可以到 Actions → feeds → Run workflow 手动跑。fork 来的仓库第一次要先在 Actions 页点一下启用。

  4. 打开 Pages:Settings → Pages → Build and deployment 选 Deploy from a branch,分支选 main,目录选 /docs,保存。

  5. 订阅:等一两分钟,打开 https://<你的用户名>.github.io/wechat-rss/,页面上列出了所有订阅源。地址长这样:

    https://<你的用户名>.github.io/wechat-rss/all.xml                       # 全部公众号合在一起
    https://<你的用户名>.github.io/wechat-rss/feeds/gh_363b924965e9.xml     # 单个公众号(RSS)
    https://<你的用户名>.github.io/wechat-rss/feeds/gh_363b924965e9.atom    # 同一个号的 Atom 版
    

    复制到 RSS 阅读器里就行。飞书和 Notion 里装一个 RSS 订阅类的机器人或集成,填这个地址即可。

生成出来是什么样

下面是一次真实运行(人民日报,打开了全文)生成的 feeds/gh_363b924965e9.xml,截取两篇:

<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
  <channel>
    <title>人民日报</title>
    <link>https://mp.weixin.qq.com/mp/profile_ext?action=home&amp;__biz=MjM5MjAxNDM4MA%3D%3D</link>
    <description>公众号「人民日报」的最新文章</description>
    <language>zh-cn</language>
    <atom:link href="https://你的用户名.github.io/wechat-rss/feeds/gh_363b924965e9.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>孙文闯,因公殉职</title>
      <link>https://mp.weixin.qq.com/s?__biz=MjM5MjAxNDM4MA%3D%3D&amp;mid=2667048044&amp;idx=1&amp;sn=f7dd7219689de98a26d2ac7d10cf4d30</link>
      <pubDate>Sun, 29 Nov 2026 09:19:57 +0000</pubDate>
      <description>&lt;p&gt;&lt;a href="https://mp.weixin.qq.com/s?..."&gt;阅读原文&lt;/a&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>一个人,拍了10万张同一条河的照片</title>
      <link>https://mp.weixin.qq.com/s?__biz=MjM5MjAxNDM4MA%3D%3D&amp;mid=2667047976&amp;idx=1&amp;sn=82dd592b489ad453d89d1d97a2d1e438</link>
      <pubDate>Sun, 29 Nov 2026 03:15:57 +0000</pubDate>
      <description>&lt;p&gt;江河,奔流不息。治水,安澜利民。&lt;/p&gt;&lt;p&gt;2016年,中共中央办公厅……&lt;/p&gt;</description>
    </item>
  </channel>
</rss>

第一篇是全文没取到的样子:只有标题、时间和原文链接。不开全文时每篇都是这样,点进去在微信里看。

设置项

在仓库的 Settings → Secrets and variables → Actions → Variables 里加,不加就用默认值:

变量 默认 说明
FULL_TEXT 0 设成 1 就给新文章取全文,订阅源里直接能读。每篇多一次调用
KEEP 50 每个订阅源保留最近多少篇
BUDGET 1 每次运行最多花多少美元,到了就停,已取到的照常写出
FEED_BASE_URL https://<用户名>.github.io/<仓库名>/ 用了自定义域名时改成你的地址

运行时间在 .github/workflows/feeds.yml 里,默认每天北京时间 8:17 和 20:17 两次。同一个号 6 小时内不会重复检查, 所以手动多点几次 Run workflow 也不会多花钱。

state.json 是状态文件,存着解析好的公众号 ID、上次检查时间和已收录的文章,Actions 每次运行后会连同 docs/ 一起提交。 删掉它就从头开始。

花多少钱

价格按 okdata 当前的价目表,脚本每次运行前会读最新价格,并打印这次最多花多少:

操作 价格
检查一个公众号(取文章列表第一页,约 10 篇) $0.02 / 次
取一篇文章的全文(FULL_TEXT=1 时,只对新文章) $0.02 / 篇
按名字搜公众号(只写了名字时,每个号只搜一次) 每个结果 $0.058,一次最多 $0.58

举例:10 个公众号,每天检查两次

  • 只要标题和链接:10 × 2 次 × 30 天 × $0.02 = 每月 $12
  • 再开全文,按每个号平均每天发 3 篇算:10 × 3 × 30 × $0.02 = 再加 $18,合计每月约 $30
  • 改成每天检查一次,列表费用减半,全文费用不变(每篇新文章只取一次)
  • 只写名字不写 ID 的号,第一次运行多一次搜索,最多 $0.58,之后不再有

在本地跑

git clone https://github.com/okdataapi/wechat-rss
cd wechat-rss
export OKDATA_API_KEY=okd_...      # 不要写进代码或提交到仓库

python3 wechat_rss.py --dry-run    # 只算钱,不调用,不需要 key
python3 wechat_rss.py              # 更新 docs/ 下的订阅源
python3 wechat_rss.py --full       # 新文章顺便取全文

其他参数:--keep N、--min-hours H、--budget USD、--accounts、--state、--out,python3 wechat_rss.py -h 能看到说明。

说明

  • 这是 okdata 的示例工具,不是微信或腾讯的官方项目。脚本只调用 okdata 的接口,本身没有爬虫。 用到的接口:公众号历史文章、 文章详情、公众号搜索。
  • 只收录公开发布的文章。订阅源是给你自己看的,开了全文的话,请尊重原作者版权,不要拿去整篇转载。 GitHub Pages 是公开的,介意的话可以把仓库设为私有并用付费计划的私有 Pages,或者只在本地跑。
  • 想一次性把某个号的历史文章存成 Markdown,可以用 wechat-article-export。
  • 测试:python3 -m unittest discover -s tests(用本地模拟服务器,不联网、不花钱)。
  • 问题和建议请提 issue。MIT 许可证。

English

Follow WeChat Official Accounts (公众号) in any RSS reader. List the accounts in accounts.txt; a scheduled GitHub Action fetches each account's latest articles through the okdata API and writes RSS 2.0 and Atom feeds (one per account plus all.xml) to docs/, which GitHub Pages serves. No QR login, no WeChat account, no cookies, no server to run. Python 3.9+, standard library only.

Set it up

  1. Fork this repository.
  2. Sign up at okdata.online and add the API key as a repository secret named OKDATA_API_KEY (Settings → Secrets and variables → Actions).
  3. Edit accounts.txt, one account per line: Name = gh_xxx, or just the name (it is searched once and the ID is kept in state.json). Committing it triggers a run; forks need Actions enabled once on the Actions tab.
  4. Settings → Pages → Deploy from a branch → main, folder /docs.
  5. Subscribe to https://<you>.github.io/wechat-rss/all.xml, or one account's feeds/<id>.xml (RSS) / feeds/<id>.atom (Atom). The page at https://<you>.github.io/wechat-rss/ lists them all.

Articles accumulate: each feed keeps the latest 50 (KEEP), even after they drop off the account's first page. An account checked in the last 6 hours is skipped, so extra manual runs cost nothing.

Options (repository variables)

FULL_TEXT=1 adds the full article text to new items (one extra call each), KEEP sets how many items each feed keeps, BUDGET caps the dollars spent per run (default 1), FEED_BASE_URL sets the public address if you use a custom domain. The schedule (twice a day) is in .github/workflows/feeds.yml.

What it costs

Checking an account is $0.02 (one page of about 10 articles), full text $0.02 per new article, and a search by name $0.058 per result, at most $0.58, once per account. Ten accounts checked twice a day is 10 × 2 × 30 × $0.02 = $12 a month; with full text and about 3 new articles per account per day, add $18, so about $30 a month. The script reads current prices and prints the most a run can cost before calling anything.

The articles are in Chinese; feed the RSS into an LLM or a reader with translation if you need English. Unofficial and not affiliated with WeChat or Tencent; the script only calls the okdata API. Public articles only: respect the authors' copyright. MIT licence.

About

公众号转 RSS,不用扫码:把微信公众号变成 RSS / Atom 订阅源,GitHub Actions 定时更新,GitHub Pages 发布。Turn WeChat Official Accounts into RSS feeds, no QR login.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages