diff --git a/docs/journal.md b/docs/journal.md index 08b397e65b..b67ca7ed90 100644 --- a/docs/journal.md +++ b/docs/journal.md @@ -150,6 +150,15 @@ _仅支持 Science 主刊_ +## Stork 文献鸟订阅 + +### 关键词 + + + +在 Stork 上注册并订阅关键词后,在 `我的` -> `关键词` 中可找到对应关键词的订阅 URL。URL 后的两个参数即为路由参数。 + + ## X-MOL 平台 ### 期刊 diff --git a/lib/router.js b/lib/router.js index a0bee89889..af80ebe879 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2756,6 +2756,9 @@ router.get('/pbc/tradeAnnouncement', require('./routes/pbc/tradeAnnouncement')); // Monotype router.get('/monotype/article', require('./routes/monotype/article')); +// Stork +router.get('/stork/keyword/:trackID/:displayKey', require('./routes/stork/keyword')); + // 致美化 router.get('/zhutix/latest', require('./routes/zhutix/latest')); diff --git a/lib/routes/stork/keyword.js b/lib/routes/stork/keyword.js new file mode 100644 index 0000000000..a18a980d6f --- /dev/null +++ b/lib/routes/stork/keyword.js @@ -0,0 +1,58 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const trackID = String(ctx.params.trackID); + const displayKey = String(ctx.params.displayKey); + + const response = await got({ + method: 'get', + url: `https://www.storkapp.me/paper/showPaperList.php?trackID=${trackID}&displayKey=${displayKey}`, + }); + + const $ = cheerio.load(response.data); + + const reg = /^Keyword: (.*) \(\d+ results\)$/; + const keyword = reg.exec($('h2').text())[1]; + const lines = $('tr'); + + const out = await Promise.all( + lines + .map(async (index, item) => { + item = $(item); + const cells = item.find('td'); + + const author = cells.eq(1).text(); + const title = cells.eq(2).text(); + const link = cells.eq(2).find('a').attr('href').replace(/^\./, ''); + const fulltext_link = `https://www.storkapp.me/paper${link}`; + const journal = cells + .eq(3) + .text() + .replace(/ \(\d+(\.\d+)?\)$/, ''); + + const description = await ctx.cache.tryGet(fulltext_link, async () => { + const result = await got.get(fulltext_link); + const $ = cheerio.load(result.data); + + return $('#abstractHolder').text(); + }); + + const result = { + title: title, + description: description, + link: fulltext_link, + author: author, + category: journal, + }; + return Promise.resolve(result); + }) + .get() + ); + + ctx.state.data = { + title: `Stork 追踪关键词:${keyword}`, + link: `https://www.storkapp.me/paper/showPaperList.php?trackID=${trackID}&displayKey=${displayKey}`, + item: out, + }; +};