diff --git a/README.md b/README.md index b7f5ba63b..4e835f24e 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇 - 主题 - 用户动态 - 微信 - - 公众号 + - 公众号(即刻来源) + - 公众号(瓦斯来源) - 网易云音乐 - 歌单歌曲 - 用户歌单 diff --git a/docs/README.md b/docs/README.md index 39c9606e3..8b1c76c5a 100644 --- a/docs/README.md +++ b/docs/README.md @@ -552,16 +552,28 @@ rid: 排行榜分区 id,默认 0 ## 微信 -### 公众号 - ::: tip 提示 -公众号抓取困难,目前可提供的方案是通过即刻的公众号主题订阅 +公众号直接抓取困难,故目前提供即刻和瓦斯两种间接抓取方案,请自行选择 ::: +### 公众号(即刻来源) + 举例: [https://rsshub.app/jike/topic/584b8ac671a288001154a115](https://rsshub.app/jike/topic/584b8ac671a288001154a115) +路由: `/jike/user/:id` + +参数: 参考 [即刻-主题-精选](#主题-精选) + +### 公众号(瓦斯来源) + +举例: [https://rsshub.app/wechat/wasi/5b5adaf358e5c4583338eace](https://rsshub.app/jike/topic/584b8ac671a288001154a115) + +路由: `/wechat/wasi/:id` + +参数: id,瓦斯公众号 id,可在[瓦斯](https://w.qnmlgb.tech/wx)搜索公众号,打开公众号页,在 URL 中找到 id + ## 网易云音乐 ### 歌单歌曲 diff --git a/router.js b/router.js index 60477da59..1a5725aa5 100755 --- a/router.js +++ b/router.js @@ -424,4 +424,7 @@ router.get('/appstore/price/:country/:type/:id', require('./routes/appstore/pric // Hopper router.get('/hopper/:lowestOnly/:from/:to?', require('./routes/hopper/index')); +// wechat +router.get('/wechat/wasi/:id', require('./routes/wechat/wasi')); + module.exports = router; diff --git a/routes/wechat/wasi.js b/routes/wechat/wasi.js new file mode 100644 index 000000000..e629cabf2 --- /dev/null +++ b/routes/wechat/wasi.js @@ -0,0 +1,28 @@ +const axios = require('../../utils/axios'); +const config = require('../../config'); + +module.exports = async (ctx) => { + const id = ctx.params.id; + + const response = await axios({ + method: 'get', + url: `https://q.qnmlgb.tech/w/api/articles?_ls=&_fmt=authorSimple&_page=author&_author_id=${id}&_sub_tab=&_tab=author`, + headers: { + 'User-Agent': config.ua, + Referer: `https://w.qnmlgb.tech/authors/${id}/`, + }, + }); + const data = response.data.result.articles[0]; + + ctx.state.data = { + title: `${data.author.nickname}微信公众号`, + link: `https://w.qnmlgb.tech/authors/${id}/`, + description: data.author.profile_desc, + item: data.sub_articles.map((item) => ({ + title: item.article.title, + description: `${item.article.digest}`, + pubDate: new Date(item.article.datetime * 1000).toUTCString(), + link: item.article.content_url, + })), + }; +};