mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-10 23:34:38 +08:00
@@ -224,6 +224,12 @@ GitHub 官方也提供了一些 RSS:
|
|||||||
|
|
||||||
<Route author="kt286" example="/v2ex/post/584403" path="/v2ex/post/:postid" :paramsDesc="['帖子ID,在 URL 可以找到']"/>
|
<Route author="kt286" example="/v2ex/post/584403" path="/v2ex/post/:postid" :paramsDesc="['帖子ID,在 URL 可以找到']"/>
|
||||||
|
|
||||||
|
## 阿里云
|
||||||
|
|
||||||
|
### 数据库内核月报
|
||||||
|
|
||||||
|
<Route author="junbaor" example="/aliyun/database_month" path="/aliyun/database_month"/>
|
||||||
|
|
||||||
## 安全客
|
## 安全客
|
||||||
|
|
||||||
::: tip 提示
|
::: tip 提示
|
||||||
|
|||||||
@@ -1582,4 +1582,7 @@ router.get('/yidoutang/case/:type', require('./routes/yidoutang/case.js'));
|
|||||||
// 开眼
|
// 开眼
|
||||||
router.get('/kaiyan/index', require('./routes/kaiyan/index'));
|
router.get('/kaiyan/index', require('./routes/kaiyan/index'));
|
||||||
|
|
||||||
|
// 阿里云
|
||||||
|
router.get('/aliyun/database_month', require('./routes/aliyun/database_month'));
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
53
lib/routes/aliyun/database_month.js
Normal file
53
lib/routes/aliyun/database_month.js
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const url = 'http://mysql.taobao.org/monthly/';
|
||||||
|
const response = await got({ method: 'get', url });
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
|
||||||
|
const list = $("ul[class='posts'] > li")
|
||||||
|
.map((i, e) => {
|
||||||
|
const element = $(e);
|
||||||
|
const title = element
|
||||||
|
.find('a')
|
||||||
|
.text()
|
||||||
|
.trim();
|
||||||
|
const link =
|
||||||
|
'http://mysql.taobao.org' +
|
||||||
|
element
|
||||||
|
.find('a')
|
||||||
|
.attr('href')
|
||||||
|
.trim();
|
||||||
|
return {
|
||||||
|
title: title,
|
||||||
|
description: '',
|
||||||
|
link: link,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.get();
|
||||||
|
|
||||||
|
const result = await Promise.all(
|
||||||
|
list.map(async (item) => {
|
||||||
|
const link = item.link;
|
||||||
|
|
||||||
|
const cache = await ctx.cache.get(link);
|
||||||
|
if (cache) {
|
||||||
|
return Promise.resolve(JSON.parse(cache));
|
||||||
|
}
|
||||||
|
|
||||||
|
const itemReponse = await got.get(link);
|
||||||
|
const itemElement = cheerio.load(itemReponse.data);
|
||||||
|
item.description = itemElement('.content').html();
|
||||||
|
|
||||||
|
ctx.cache.set(link, JSON.stringify(item));
|
||||||
|
return Promise.resolve(item);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: $('title').text(),
|
||||||
|
link: url,
|
||||||
|
item: result.reverse(),
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user