mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat(route): add ScienceDirect Journal (#8399)
This commit is contained in:
@@ -201,6 +201,12 @@ Subscribe to the cover images of the Nature journals, and get the latest publica
|
||||
|
||||
<RouteEn author="yech1990" example="/pubmed/trending" path="/pubmed/trending" supportScihub="1"/>
|
||||
|
||||
## ScienceDirect
|
||||
|
||||
### Journal
|
||||
|
||||
<RouteEn author="nczitzk" example="/sciencedirect/journal/research-policy" path="/sciencedirect/journal/:id" :paramsDesc="['Journal id, can be found in URL']"/>
|
||||
|
||||
## Science Journal
|
||||
|
||||
### Current Issue
|
||||
|
||||
@@ -209,6 +209,12 @@ _仅支持 Science 主刊_
|
||||
|
||||
</Route>
|
||||
|
||||
## ScienceDirect
|
||||
|
||||
### Journal
|
||||
|
||||
<Route author="nczitzk" example="/sciencedirect/journal/research-policy" path="/sciencedirect/journal/:id" :paramsDesc="['期刊 id,可在对应期刊页 URL 中找到']"/>
|
||||
|
||||
## Stork 文献鸟订阅
|
||||
|
||||
### 关键词
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id;
|
||||
|
||||
const rootUrl = 'https://sciencedirect.com';
|
||||
const currentUrl = `${rootUrl}/journal/${id}/articles-in-press`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const issn = response.data.match(/ISSN(\d{8})'/)[1];
|
||||
|
||||
const apiUrl = `${rootUrl}/journal/${issn}/articles-in-press/articles?path=/journal/${id}/articles-in-press&title=${id}`;
|
||||
|
||||
const apiResponse = await got({
|
||||
method: 'get',
|
||||
url: apiUrl,
|
||||
headers: {
|
||||
cookie: response.headers['set-cookie'].map((cookie) => cookie.split(';Version=1;')[0]).join('; '),
|
||||
},
|
||||
});
|
||||
|
||||
const list = apiResponse.data.data.results.map((item) => ({
|
||||
doi: item.doi,
|
||||
title: item.title,
|
||||
link: `${rootUrl}${item.href}`,
|
||||
pubDate: parseDate(item.coverDateStart),
|
||||
enclosure_url: `${rootUrl}${item.pdfDownload.url}`,
|
||||
author: item.authors.map((author) => `${author.givenName} ${author.surname}`).join(', '),
|
||||
}));
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
const abstracts = content('.Abstracts').html() ?? '';
|
||||
const keywords = content('.Keywords').html() ?? '';
|
||||
|
||||
item.description = abstracts + keywords;
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${response.data.match(/\\"displayName\\":\\"(.*?)\\",\\"/)[1]} - ScienceDirect`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/journal/:id': ['nczitzk'],
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'sciencedirect.com': {
|
||||
_name: 'ScienceDirect',
|
||||
'.': [
|
||||
{
|
||||
title: 'Journal',
|
||||
docs: 'https://docs.rsshub.app/journal.html#sciencedirect-journal',
|
||||
source: ['/journal/:id', '/'],
|
||||
target: '/sciencedirect/journal/:id',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/journal/:id', require('./journal'));
|
||||
};
|
||||
Reference in New Issue
Block a user