mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 14:40:23 +08:00
feat: 添加了 Stork 文献鸟关键词追踪路由 (#4853)
This commit is contained in:
committed by
GitHub
parent
fe9b8fec3d
commit
0440485e2e
@@ -150,6 +150,15 @@ _仅支持 Science 主刊_
|
||||
|
||||
</Route>
|
||||
|
||||
## Stork 文献鸟订阅
|
||||
|
||||
### 关键词
|
||||
|
||||
<Route author="xraywu" example="/stork/keyword/409159/R4j3Hbn5ia" path="/stork/keyword/:trackID/:displayKey" :paramsDesc="['关键词订阅 URL 上的 trackID 参数','关键词订阅 URL 上的 displayKey 参数']">
|
||||
|
||||
在 Stork 上注册并订阅关键词后,在 `我的` -> `关键词` 中可找到对应关键词的订阅 URL。URL 后的两个参数即为路由参数。
|
||||
|
||||
</Route>
|
||||
## X-MOL 平台
|
||||
|
||||
### 期刊
|
||||
|
||||
@@ -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'));
|
||||
|
||||
|
||||
58
lib/routes/stork/keyword.js
Normal file
58
lib/routes/stork/keyword.js
Normal file
@@ -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,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user