mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-19 06:38:55 +08:00
feat(route): 增加HelloGithub的RSS订阅 (#8879)
* 增加HelloGithub的RSS订阅 * refactor: migrate to v2 Co-authored-by: TonyRL <TonyRL@users.noreply.github.com>
This commit is contained in:
39
lib/v2/hellogithub/ranking.js
Normal file
39
lib/v2/hellogithub/ranking.js
Normal file
@@ -0,0 +1,39 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
let type;
|
||||
switch (ctx.params.type) {
|
||||
case 'db':
|
||||
type = 'db-engines';
|
||||
break;
|
||||
case 'webserver':
|
||||
type = 'netcraft';
|
||||
break;
|
||||
default:
|
||||
type = 'tiobe';
|
||||
break;
|
||||
}
|
||||
const rootUrl = 'https://hellogithub.com/report/' + type;
|
||||
ctx.state.data = {
|
||||
title: 'HelloGitHub - ranking',
|
||||
link: rootUrl,
|
||||
item: await ctx.cache.tryGet(rootUrl, async () => {
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: rootUrl,
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
const content = $('.content');
|
||||
const title = $('.header').find('h1');
|
||||
|
||||
return [
|
||||
{
|
||||
title: title.text(),
|
||||
link: rootUrl,
|
||||
description: content.html(),
|
||||
},
|
||||
];
|
||||
}),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user