feat(route): add Springer route (#9951)
* feat(route): add dependence * feat(route): add environment files * feat: add springer script * feat: make doi link format * feat: make springer done * feat: remove get abstract * feat: remove get abstract * feat: remove some commit * feat: springer done * feat(fix): remove "abstract" * feat(fix): update route * feat: update docs/journal.md and docs/en/journal.md * feat: add journal path * feat: uniform route path * Update docs/en/journal.md Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/v2/springer/journal.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/v2/springer/templates/description.art Co-authored-by: Tony <TonyRL@users.noreply.github.com> Co-authored-by: Derekmini <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>>
This commit is contained in:
parent
213b1140f0
commit
cd814670dc
|
|
@ -352,6 +352,12 @@ _only support Science Journal_
|
|||
|
||||
<RouteEn author="nczitzk" example="/sciencedirect/journal/research-policy" path="/sciencedirect/journal/:id" :paramsDesc="['Journal id, can be found in URL']"/>
|
||||
|
||||
## Springer
|
||||
|
||||
### Journal
|
||||
|
||||
<RouteEn author="Derekmini TonyRL" example="/springer/journal/10450" path="/springer/journal/:journal" :paramsDesc="['Journal Code, the number in the URL from the journal homepage']" radar="1" rssbud="1"/>
|
||||
|
||||
## X-MOL Platform
|
||||
|
||||
### Journal
|
||||
|
|
|
|||
|
|
@ -319,6 +319,12 @@ You can get all short name of a journal from <https://www.nature.com/siteindex>
|
|||
|
||||
<Route author="nczitzk" example="/sciencedirect/journal/research-policy" path="/sciencedirect/journal/:id" :paramsDesc="['期刊 id,可在对应期刊页 URL 中找到']"/>
|
||||
|
||||
## Springer
|
||||
|
||||
### 期刊
|
||||
|
||||
<Route author="Derekmini TonyRL" example="/springer/journal/10450" path="/springer/journal/:journal" :paramsDesc="['期刊代码,期刊主页 URL 中的数字']" radar="1" rssbud="1"/>
|
||||
|
||||
## Stork 文献鸟订阅
|
||||
|
||||
### 关键词
|
||||
|
|
|
|||
|
|
@ -0,0 +1,72 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const path = require('path');
|
||||
const { art } = require('@/utils/render');
|
||||
|
||||
const { CookieJar } = require('tough-cookie');
|
||||
const cookieJar = new CookieJar();
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const host = 'https://www.springer.com';
|
||||
const journal = ctx.params.journal;
|
||||
const jrnlUrl = `${host}/journal/${journal}`;
|
||||
|
||||
const response = await got(jrnlUrl, {
|
||||
cookieJar,
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
const jrnlName = $('h1#journalTitle').text().trim();
|
||||
const issueUrl = $('p.c-card__title.u-mb-16.u-flex-grow').find('a').attr('href');
|
||||
|
||||
const response2 = await got(issueUrl, {
|
||||
cookieJar,
|
||||
});
|
||||
const $2 = cheerio.load(response2.data);
|
||||
const issue = $2('.app-volumes-and-issues__info').find('h1').text();
|
||||
const list = $2('article.c-card')
|
||||
.map((_, item) => {
|
||||
const title = $(item).find('.c-card__title').text().trim();
|
||||
const link = $(item).find('a').attr('href');
|
||||
const doi = link.replace('https://link.springer.com/article/', '');
|
||||
const img = $(item).find('img').attr('src');
|
||||
const authors = $(item)
|
||||
.find('.c-author-list')
|
||||
.find('li')
|
||||
.map((_, item) => $(item).text().trim())
|
||||
.get()
|
||||
.join('; ');
|
||||
return {
|
||||
title,
|
||||
link,
|
||||
doi,
|
||||
issue,
|
||||
img,
|
||||
authors,
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const renderDesc = (item) =>
|
||||
art(path.join(__dirname, 'templates/description.art'), {
|
||||
item,
|
||||
});
|
||||
await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const response3 = await got(item.link, {
|
||||
cookieJar,
|
||||
});
|
||||
const $3 = cheerio.load(response3.data);
|
||||
$3('.c-article__sub-heading').remove();
|
||||
item.abstract = $3('div#Abs1-content').text();
|
||||
item.description = renderDesc(item);
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
ctx.state.data = {
|
||||
title: jrnlName,
|
||||
link: jrnlUrl,
|
||||
item: list,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/journal/:journal': ['Derekmini', 'TonyRL'],
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'springer.com': {
|
||||
_name: 'Springer',
|
||||
www: [
|
||||
{
|
||||
title: 'latest',
|
||||
docs: 'https://docs.rsshub.app/journal.html#Springer',
|
||||
source: '/journal/:journal/*',
|
||||
target: '/springer/journal/:journal',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/journal/:journal', require('./journal'));
|
||||
};
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<p>
|
||||
<span><big>{{ item.title }}</big></span><br>
|
||||
</p>
|
||||
<p>
|
||||
<span><small><i>{{ item.authors }}</i></small></span><br>
|
||||
<span><small><i>https://doi.org/{{ item.doi }}</i></small></span><br>
|
||||
<span><small><i>{{ item.issue }}</i></small></span><br>
|
||||
<img src={{ item.img }}>
|
||||
</p>
|
||||
<p>
|
||||
<span>{{ item.abstract }}</span><br>
|
||||
</p>
|
||||
Loading…
Reference in New Issue