diff --git a/README.md b/README.md index 63d38b6d7..d0785fb00 100644 --- a/README.md +++ b/README.md @@ -216,6 +216,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇 - 焦点专题 - Greasy Fork - 脚本更新 +- LinkedKeeper + - 博文 diff --git a/docs/README.md b/docs/README.md index d3ab6686d..b124788ca 100644 --- a/docs/README.md +++ b/docs/README.md @@ -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` diff --git a/router.js b/router.js index fbb33b629..f00a3acf4 100755 --- a/router.js +++ b/router.js @@ -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; diff --git a/routes/linkedkeeper/index.js b/routes/linkedkeeper/index.js new file mode 100644 index 000000000..e9f3b8c56 --- /dev/null +++ b/routes/linkedkeeper/index.js @@ -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(), + }; +};