mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-10 23:34:38 +08:00
rss: new /rsshub/rss
This commit is contained in:
@@ -4,33 +4,40 @@ const cheerio = require('cheerio');
|
||||
module.exports = async (ctx) => {
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: 'https://github.com/DIYgod/RSSHub/releases.atom',
|
||||
headers: {
|
||||
Referer: 'https://github.com/DIYgod/RSSHub',
|
||||
},
|
||||
url: 'https://docs.rsshub.app',
|
||||
});
|
||||
|
||||
const data = response.data;
|
||||
|
||||
const $ = cheerio.load(data, {
|
||||
xmlMode: true,
|
||||
});
|
||||
const list = $('entry');
|
||||
const $ = cheerio.load(data);
|
||||
const list = $('.routeBlock');
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'RSSHub 有新的 RSS 支持',
|
||||
link: 'https://github.com/DIYgod/RSSHub',
|
||||
title: 'RSSHub 有新路由啦',
|
||||
link: 'https://docs.rsshub.app',
|
||||
description: '万物皆可 RSS',
|
||||
item:
|
||||
list &&
|
||||
list
|
||||
.map((index, item) => {
|
||||
item = $(item);
|
||||
item.find('.header-anchor').remove();
|
||||
const titleEle = item.prevAll('h3').eq(0);
|
||||
return {
|
||||
title: item.find('title').text(),
|
||||
description: item.find('content').text(),
|
||||
pubDate: item.find('updated').text(),
|
||||
link: item.find('link').attr('href'),
|
||||
title: `${titleEle.text().slice(2)} - ${item
|
||||
.find('.name')
|
||||
.contents()
|
||||
.eq(0)
|
||||
.text()}`,
|
||||
description: item.html(),
|
||||
link: `https://docs.rsshub.app#${encodeURIComponent(
|
||||
titleEle.find('.header-anchor').attr('href') &&
|
||||
titleEle
|
||||
.find('.header-anchor')
|
||||
.attr('href')
|
||||
.slice(1)
|
||||
)}`,
|
||||
guid: item.attr('id'),
|
||||
};
|
||||
})
|
||||
.get(),
|
||||
|
||||
Reference in New Issue
Block a user