mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat(route): add dbaplus社群 (#7150)
Co-authored-by: NeverBehave <gayhub@never.pet>
This commit is contained in:
co-authored by
NeverBehave
parent
e1033c6535
commit
090a595cf5
@@ -30,6 +30,16 @@ pageClass: routes
|
||||
|
||||
<Route author="fengkx" example="/cve/search/PostgreSQL" path="/cve/search/:keyword" :paramsDesc="['关键词']" />
|
||||
|
||||
## dbaplus 社群
|
||||
|
||||
<Route author="nczitzk" example="/dbaplus" path="/dbaplus/:tab?" :paramsDesc="['栏目,见下表,默认为全部']">
|
||||
|
||||
| 全部 | 数据库 | 运维 | 大数据 | 架构 | PaaS 云 | 职场生涯 | 这里有毒 |
|
||||
| ---- | ------ | ---- | ------ | ---- | ------- | -------- | -------- |
|
||||
| All | 153 | 134 | 73 | 141 | 72 | 149 | 21 |
|
||||
|
||||
</Route>
|
||||
|
||||
## deeplearning.ai
|
||||
|
||||
### TheBatch 周报
|
||||
|
||||
@@ -4042,6 +4042,9 @@ router.get('/wainao-reads/all-articles', require('./routes/wainao/index'));
|
||||
// react
|
||||
router.get('/react/react-native-weekly', require('./routes/react/react-native-weekly'));
|
||||
|
||||
// dbaplus 社群
|
||||
router.get('/dbaplus/:tab?', require('./routes/dbaplus/tab'));
|
||||
|
||||
// 梨园
|
||||
router.get('/liyuan-forums/threads', require('./routes/liyuan-forums/threads'));
|
||||
router.get('/liyuan-forums/threads/forum/:forum_id', require('./routes/liyuan-forums/threads'));
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const tab = ctx.params.tab || 'All';
|
||||
|
||||
const rootUrl = 'https://dbaplus.cn';
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: rootUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $(`#tab${tab} li`)
|
||||
.slice(0, 15)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
|
||||
return {
|
||||
link: item.find('a').eq(0).attr('href'),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.title = content('h2.title').text();
|
||||
item.author = content('span.user').text();
|
||||
item.description = content('.new-detailed').html();
|
||||
item.pubDate = new Date(content('span.time').eq(0).text()).toUTCString();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${response.data.match(`<a href="#tab${tab}" data-toggle="tab">(.*)</a>`)[1]} - dbaplus社群`,
|
||||
link: rootUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user