Add LinkedKeeper close #197 (#438)

This commit is contained in:
imlonghao
2018-08-09 11:24:50 +08:00
committed by DIYgod
parent 213342211d
commit a19b872f73
4 changed files with 81 additions and 0 deletions

View File

@@ -216,6 +216,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
- 焦点专题
- Greasy Fork
- 脚本更新
- LinkedKeeper
- 博文
</details>

View File

@@ -1740,3 +1740,17 @@ id用户 id可在用户主页 URL 中找到
language语言可在网站右上角找到 `all` 为所有语言
domain按脚本生效域名过滤可选
## LinkedKeeper
### 博文
举例: [https://rsshub.app/linkedkeeper/sub/1](https://rsshub.app/linkedkeeper/sub/1)
路由: `/linkedkeeper/:type/:id?`
参数:
type博文分类为 URL 中 `.action` 的文件名
id可选分区或标签的 ID对应 URL 中的 `sid``tid`

View File

@@ -393,4 +393,7 @@ router.get('/xueqiu/favorite/:id', require('./routes/xueqiu/favorite'));
// Greasy Fork
router.get('/greasyfork/:language/:domain?', require('./routes/greasyfork/scripts'));
// LinkedKeeper
router.get('/linkedkeeper/:type/:id?', require('./routes/linkedkeeper/index'));
module.exports = router;

View File

@@ -0,0 +1,62 @@
const axios = require('../../utils/axios');
const cheerio = require('cheerio');
const config = require('../../config');
module.exports = async (ctx) => {
const type = ctx.params.type;
const id = ctx.params.id;
const res = await axios({
method: 'get',
url: `http://www.linkedkeeper.com/list/${type}.action`,
params: {
sid: id,
tid: id,
},
headers: {
'User-Agent': config.ua,
},
});
const data = res.data;
const $ = cheerio.load(data);
const list = $('tbody').find('td');
ctx.state.data = {
title: `${$('.blog_en_title')
.text()
.trim() ||
$('.active')
.text()
.trim()} - LinkedKeeper`,
link: res.request.res.responseUrl,
item: list
.map((index, item) => {
item = $(item);
const pubDate = new Date(
item
.find('dd:nth-child(3)')
.text()
.trim()
.replace('月', '-')
.replace('日', '')
);
pubDate.setFullYear(new Date().getFullYear());
return {
title: item
.find('a.blog_weight')
.text()
.trim(),
description: `${item
.find('a.blog_weight')
.text()
.trim()} - ${item
.find('.blog_author_13')
.text()
.trim()}`,
pubDate: pubDate.toUTCString(),
link: `http://www.linkedkeeper.com${item.find('a').attr('href')}`,
};
})
.get(),
};
};