mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +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:
@@ -311,6 +311,26 @@ GitHub 官方也提供了一些 RSS:
|
||||
|
||||
<Route author="cf020031308 nczitzk xie-dongping" example="/hackernews/threads/comments_list/dang" path="/hackernews/:section?/:type?/:user?" :paramsDesc="['内容分区,见上表,默认为 `index`', '链接类型,见上表,默认为 `sources`', '设定用户,只在 `threads` 和 `submitted` 分区有效']" />
|
||||
|
||||
## HelloGitHub
|
||||
|
||||
### 文章列表
|
||||
|
||||
<Route author="moke8" example="/hellogithub/article" path="/hellogithub/article"/>
|
||||
|
||||
### 编程语言排行榜
|
||||
|
||||
<Route author="moke8" example="/hellogithub/ranking" path="/hellogithub/ranking/:type?" :paramsDesc="['分类,见下表']">
|
||||
|
||||
| 编程语言排行 | 数据库排行 | 服务端语言排行 |
|
||||
| ------ | ----- | --------- |
|
||||
| tiobe | db | webserver |
|
||||
|
||||
</Route>
|
||||
|
||||
### 月刊
|
||||
|
||||
<Route author="moke8" example="/hellogithub/month" path="/hellogithub/month"/>
|
||||
|
||||
## Hex-Rays
|
||||
|
||||
### Hex-Rays News
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'https://hellogithub.com';
|
||||
const currentUrl = 'https://hellogithub.com/article';
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('.content .post')
|
||||
.slice(0, 10)
|
||||
.map((_, item) => {
|
||||
const a = $(item).find('a.post-title').eq(0).eq(0);
|
||||
const link = rootUrl + a.attr('href');
|
||||
return {
|
||||
title: a.text(),
|
||||
link,
|
||||
description: $(item).find('.post-description')[0].children[0].data,
|
||||
pubDate: timezone(parseDate($(item).find('.post-meta').text(), 'YYYY-MM-DD HH:mm:ss'), +8),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
item.description = content('.markdown-body').html();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'HelloGitHub - Article',
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
'/article': ['moke8'],
|
||||
'/ranking/:type?': ['moke8'],
|
||||
'/month': ['moke8'],
|
||||
};
|
||||
@@ -0,0 +1,42 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'https://hellogithub.com';
|
||||
const currentUrl = 'https://hellogithub.com/article';
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: rootUrl,
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
let count = $('.pricing-table-price').eq(0).text();
|
||||
count = count.replace(/[^0-9]/gi, '');
|
||||
let start = count - 10;
|
||||
const PromiseArr = [];
|
||||
for (start; start <= count; start++) {
|
||||
PromiseArr.push(
|
||||
new Promise((resolve) => {
|
||||
const link = `https://hellogithub.com/periodical/volume/${start}/`;
|
||||
const issueNum = start;
|
||||
return ctx.cache.tryGet(link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: link,
|
||||
});
|
||||
const $ = cheerio.load(detailResponse.data);
|
||||
return resolve({
|
||||
title: '第' + issueNum + '期',
|
||||
link,
|
||||
description: $('.content').html(),
|
||||
});
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
const items = await Promise.all(PromiseArr);
|
||||
ctx.state.data = {
|
||||
title: 'HelloGitHub - Article',
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
module.exports = {
|
||||
'hellogithub.com': {
|
||||
_name: 'HelloGitHub',
|
||||
'.': [
|
||||
{
|
||||
title: '文章列表',
|
||||
docs: 'https://docs.rsshub.app/programming.html#hellogithub',
|
||||
source: ['/article', '/article/?url=/periodical/volume/'],
|
||||
target: '/hellogithub/article',
|
||||
},
|
||||
{
|
||||
title: '编程语言排行榜',
|
||||
docs: 'https://docs.rsshub.app/programming.html#hellogithub',
|
||||
source: '/report/:type/?url=/periodical/volume/',
|
||||
target: '/hellogithub/ranking/:type',
|
||||
},
|
||||
{
|
||||
title: '月刊',
|
||||
docs: 'https://docs.rsshub.app/programming.html#hellogithub',
|
||||
source: '/periodical/volume/',
|
||||
target: '/hellogithub/month',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -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(),
|
||||
},
|
||||
];
|
||||
}),
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/article', require('./article'));
|
||||
router.get('/month', require('./month'));
|
||||
router.get('/ranking/:type?', require('./ranking'));
|
||||
};
|
||||
Reference in New Issue
Block a user