diff --git a/README.md b/README.md index c6a3ce44b7..5ce9c3fc98 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇 当前支持列表: +* RSSHub + * 支持的 RSS * bilibili * 番剧 * UP 主投稿 diff --git a/docs/README.md b/docs/README.md index 75cd3fba8e..4426f3bcce 100644 --- a/docs/README.md +++ b/docs/README.md @@ -27,6 +27,16 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇 举例: [https://rsshub.app/bilibili/user/coin/2267573?filter=微小微|赤九玖|暴走大事件](https://rsshub.app/bilibili/user/coin/2267573?filter=微小微|赤九玖|暴走大事件) +## RSSHub + +### 支持的 RSS + +举例: [https://rsshub.app/rsshub/rss](https://rsshub.app/rsshub/rss) + +路由: `/rsshub/rss` + +参数: 无 + ## bilibili ### 番剧 diff --git a/router.js b/router.js index cb7333aba1..4eedda8448 100644 --- a/router.js +++ b/router.js @@ -71,6 +71,9 @@ router.get('/', async (ctx) => { }); }); +// RSSHub +router.get('/rsshub/rss', require('./routes/rsshub/rss')); + // bilibili router.get('/bilibili/user/video/:uid', require('./routes/bilibili/video')); router.get('/bilibili/user/fav/:uid', require('./routes/bilibili/fav')); diff --git a/routes/rsshub/rss.js b/routes/rsshub/rss.js new file mode 100644 index 0000000000..0587b683ce --- /dev/null +++ b/routes/rsshub/rss.js @@ -0,0 +1,40 @@ +const axios = require('axios'); +const cheerio = require('cheerio'); +const config = require('../../config'); + +module.exports = async (ctx) => { + const response = await axios({ + method: 'get', + url: 'https://github.com/DIYgod/RSSHub/releases.atom', + headers: { + 'User-Agent': config.ua, + Referer: 'https://github.com/DIYgod/RSSHub', + }, + }); + + const data = response.data; + + const $ = cheerio.load(data, { + xmlMode: true, + }); + const list = $('entry'); + + ctx.state.data = { + title: 'RSSHub 有新的 RSS 支持', + link: 'https://github.com/DIYgod/RSSHub', + description: '使用 RSS 连接全世界', + item: + list && + list + .map((index, item) => { + item = $(item); + return { + title: item.find('title').text(), + description: item.find('content').text(), + pubDate: item.find('updated').text(), + link: item.find('link').attr('href'), + }; + }) + .get(), + }; +};