mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-16 02:42:57 +08:00
fix /rsshub/rss for new docs
This commit is contained in:
@@ -2,28 +2,36 @@ const axios = require('../../utils/axios');
|
|||||||
const cheerio = require('cheerio');
|
const cheerio = require('cheerio');
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
const response = await axios({
|
const types = ['social-media', 'programming', 'live', 'multimedia', 'picture', 'anime', 'program-update', 'university', 'traditional-media', 'forecast', 'travel', 'shopping', 'game', 'reading', 'government', 'other'];
|
||||||
method: 'get',
|
const all = await Promise.all(
|
||||||
url: 'https://docs.rsshub.app',
|
types.map(async (type) => {
|
||||||
|
const response = await axios({
|
||||||
|
method: 'get',
|
||||||
|
url: `https://docs.rsshub.app/${type}.html`,
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = response.data;
|
||||||
|
|
||||||
|
const $ = cheerio.load(data);
|
||||||
|
const item = $('.routeBlock').get();
|
||||||
|
return Promise.resolve(item);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
let list = [];
|
||||||
|
all.forEach((item) => {
|
||||||
|
list = list.concat(item);
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = response.data;
|
|
||||||
|
|
||||||
const $ = cheerio.load(data);
|
|
||||||
const list = $('.routeBlock')
|
|
||||||
.get()
|
|
||||||
.reverse();
|
|
||||||
|
|
||||||
ctx.state.data = {
|
ctx.state.data = {
|
||||||
title: 'RSSHub 有新路由啦',
|
title: 'RSSHub 有新路由啦',
|
||||||
link: 'https://docs.rsshub.app',
|
link: 'https://docs.rsshub.app',
|
||||||
description: '万物皆可 RSS',
|
description: '万物皆可 RSS',
|
||||||
item:
|
item:
|
||||||
list &&
|
list &&
|
||||||
list.map((item) => {
|
list.reverse().map((item) => {
|
||||||
item = $(item);
|
item = cheerio(item);
|
||||||
item.find('.header-anchor').remove();
|
item.find('.header-anchor').remove();
|
||||||
const titleEle = item.prevAll('h3').eq(0);
|
const titleEle = item.prevAll('h2').eq(0);
|
||||||
return {
|
return {
|
||||||
title: `${titleEle[0].attribs.id} - ${item
|
title: `${titleEle[0].attribs.id} - ${item
|
||||||
.find('.name')
|
.find('.name')
|
||||||
|
|||||||
Reference in New Issue
Block a user