mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 22:19:40 +08:00
* 增加HelloGithub的RSS订阅 * refactor: migrate to v2 Co-authored-by: TonyRL <TonyRL@users.noreply.github.com>
40 lines
1.0 KiB
JavaScript
40 lines
1.0 KiB
JavaScript
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(),
|
|
},
|
|
];
|
|
}),
|
|
};
|
|
};
|