mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat(route): add howtoforge (#14538)
* add howtoforge * Update study.mdx * 更新 rss.js * 更新 radar.js * 更新 radar.js
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/': ['cnkmmk'],
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'howtoforge.com': {
|
||||
_name: "Howtoforge Linux Tutorials",
|
||||
'.': [
|
||||
{
|
||||
title: '学习',
|
||||
docs: 'https://docs.rsshub.app/routes/study#howtoforge-linux-tutorials',
|
||||
source: ['/'],
|
||||
target: '/howtoforge',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/', require('./rss'));
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const currentUrl = 'https://www.howtoforge.com';
|
||||
const response = await got(`${currentUrl}/feed.rss`);
|
||||
const $ = cheerio.load(response.data, { xmlMode: true });
|
||||
const titleMain = $('channel > title').text();
|
||||
const descriptionMain = $('channel > description').text();
|
||||
const items = $('channel > item')
|
||||
.map((_, item) => {
|
||||
const $item = $(item);
|
||||
const link = $item.find('link').text();
|
||||
const title = $item.find('title').text();
|
||||
const description = $item.find('description').text();
|
||||
const pubDate = $item.find('pubDate').text();
|
||||
return {
|
||||
link,
|
||||
pubDate, // no need to normalize because it's from a valid RSS feed
|
||||
title,
|
||||
description,
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
ctx.state.data = {
|
||||
title: titleMain,
|
||||
description: descriptionMain,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user