fix(route): update v2/scitation to v2/aip (#12955)

* fix(route): scitation/journal

* fix(docs): scitation/journal

* fix(docs): (en) scitation/journal

* chores

* fix(radar): scitation/journal

* fix(radar): scitation/journal

* fix(radar): scitation/journal

* style: auto format

* fix(route): mv scitation to aip

* fix(route): v2/AIP chores

* fix(docs): v2/aip docs

* fix(docs): chores: jounus/advanced/advanced-feed

* fix(docs): update en docs

* fix(docs): not right close the <RouteEn>

* fix(docs): correct some mistake

* Update lib/v2/aip/radar.js

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Derek
2023-08-19 20:44:11 +08:00
committed by GitHub
co-authored by github-actions[bot]
parent e455b54fbb
commit 8d4dbb9a80
13 changed files with 107 additions and 123 deletions
@@ -6,8 +6,8 @@ const { isValidHost } = require('@/utils/valid-host');
module.exports = async (ctx) => {
const pub = ctx.params.pub;
const jrn = ctx.params.jrn;
const host = `https://${pub}.scitation.org`;
const jrnlUrl = `${host}/toc/${jrn}/current?size=all`;
const host = `https://pubs.aip.org`;
const jrnlUrl = `${host}/${pub}/${jrn}/issue`;
if (!isValidHost(pub)) {
throw Error('Invalid pub');
}
+55
View File
@@ -0,0 +1,55 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { renderDesc } = require('./utils');
module.exports = async (ctx) => {
const pub = ctx.params.pub;
const jrn = ctx.params.jrn;
const host = `https://pubs.aip.org`;
const jrnlUrl = `${host}/${pub}/${jrn}/issue`;
const { data: response } = await got.get(jrnlUrl);
const $ = cheerio.load(response);
const jrnlName = $('meta[property="og:title"]')
.attr('content')
.match(/(?:[^=]*=)?\s*([^>]+)\s*/)[1];
const publication = $('.al-article-item-wrap.al-normal');
const list = publication
.map((_, item) => {
const title = $(item).find('.item-title a:first').text();
const link = $(item).find('.item-title a:first').attr('href');
const doilink = $(item).find('.citation-label a').attr('href');
const doi = doilink && doilink.match(/10\.\d+\/\S+/)[0];
const id = $(item).find('h5[data-resource-id-access]').data('resource-id-access');
const authors = $(item)
.find('.al-authors-list')
.find('a')
.map(function () {
return $(this).text();
})
.get()
.join('; ');
const imgUrl = $(item).find('.issue-featured-image a img').attr('src');
const img = imgUrl ? imgUrl.replace(/\?.+$/, '') : '';
const description = renderDesc(title, authors, doi, img);
return {
title,
link,
doilink,
id,
authors,
img,
doi,
description,
};
})
.get();
ctx.state.data = {
title: jrnlName,
link: jrnlUrl,
item: list,
allowEmpty: true,
};
};
@@ -1,4 +1,3 @@
module.exports = {
'/:pub/:jrn': ['Derekmini', 'auto-bot-ty'],
'/:pub/:jrn/:sec': ['Derekmini', 'auto-bot-ty'],
};
+13
View File
@@ -0,0 +1,13 @@
module.exports = {
'aip.org': {
_name: 'American Institute of Physics',
pubs: [
{
title: 'Journal',
docs: 'https://docs.rsshub.app/routes/journal#american-institute-of-physics',
source: '/:pub/:jrn',
target: '/aip/:pub/:jrn',
},
],
},
};
+4
View File
@@ -0,0 +1,4 @@
module.exports = function (router) {
router.get('/:pub/:jrn', require('./journal'));
// router.get('/:pub/:jrn', require('./journal-pupp')); // Switch to this route if the official website blocks the "got" method.
};
-19
View File
@@ -1,19 +0,0 @@
module.exports = {
'scitation.org': {
_name: 'scitation',
'.': [
{
title: 'journal',
docs: 'https://docs.rsshub.app/routes/journal#scitation',
source: ':pub.scitation.org/toc/:jrn',
target: '/scitation/:pub/:jrn',
},
{
title: 'section',
docs: 'https://docs.rsshub.app/routes/journal#scitation',
source: ':pub.scitation.org/toc/:jrn',
target: (params, url) => `/scitation/:pub/:jrn/${new URL(url).searchParams.get('tocSection')}`,
},
],
},
};
-4
View File
@@ -1,4 +0,0 @@
module.exports = function (router) {
router.get('/:pub/:jrn', require('./journal'));
router.get('/:pub/:jrn/:sec', require('./section'));
};
-76
View File
@@ -1,76 +0,0 @@
const cheerio = require('cheerio');
const { puppeteerGet, renderDesc } = require('./utils');
const config = require('@/config').value;
const { isValidHost } = require('@/utils/valid-host');
module.exports = async (ctx) => {
const pub = ctx.params.pub;
const jrn = ctx.params.jrn;
const sec = ctx.params.sec.split('+').join(' ');
const host = `https://${pub}.scitation.org`;
const jrnlUrl = `${host}/toc/${jrn}/current?size=all`;
if (!isValidHost(pub)) {
throw Error('Invalid pub');
}
// use Puppeteer due to the obstacle by cloudflare challenge
const browser = await require('@/utils/puppeteer')();
const response = await puppeteerGet(jrnlUrl, browser);
const $ = cheerio.load(response);
const jrnlName = $('.header-journal-title').text();
const issueUrl = $('.row.js_issue.highlighted').find('a').attr('href');
const section = $('.subject-heading')
.toArray()
.map((item) => ({
name: $(item).text(),
}));
let ifContainSection = false;
for (let i = 0, l = section.length; i < l; i++) {
if (section[i].name === sec) {
ifContainSection = true;
}
}
let list;
if (ifContainSection === true) {
const secUrl = `${issueUrl}?tocSection=${sec}`;
list = await ctx.cache.tryGet(
secUrl,
async () => {
const response2 = await puppeteerGet(secUrl, browser);
const $2 = cheerio.load(response2);
list = $2('.card')
.toArray()
.map((item) => {
$2(item).find('.access-text').remove();
const title = $2(item).find('.hlFld-Title').text();
const authors = $2(item).find('.entryAuthor.all').text();
const img = $2(item).find('img').attr('src');
const link = $2(item).find('.ref.nowrap').attr('href');
const doi = link.replace('/doi/full/', '');
const description = renderDesc(title, authors, doi, img);
return {
title,
link,
doi,
description,
};
});
return list;
},
config.cache.routeExpire,
false
);
}
browser.close();
ctx.state.data = {
title: jrnlName.concat(' - ', sec),
link: jrnlUrl,
item: list,
allowEmpty: true,
};
};
@@ -113,7 +113,7 @@ ctx.state.data = {
### 更新文档
要显示您制作的期刊订阅源支持 Sui-hub 功能,您需要将 `Route` 组件的 `supportScihub` 属性设置为 `"1"`。以下是一个示例:
要显示您制作的期刊订阅源支持 Sci-hub 功能,您需要将 `Route` 组件的 `supportScihub` 属性设置为 `"1"`。以下是一个示例:
```vue
<Route author="..." example="..." path="..." supportScihub="1" />
+16 -10
View File
@@ -61,6 +61,22 @@ import Route from '@site/src/components/Route';
</Route>
## American Institute of Physics {#american-institute-of-physics}
### Journal {#american-institute-of-physics-journal}
<Route author="Derekmini auto-bot-ty" example="/aip/aapt/ajp" path="/aip/:pub/:jrn" paramsDesc={['出版社 id','期刊 id']} radar="1" rssbud="1" supportScihub="1">
参考 URL 格式 `pubs.aip.org/:pub/:jrn`
:::tip 提示
更多期刊可在 [AIP Publications](https://publishing.aip.org/publications/find-the-right-journal) 中找到。
:::
</Route>
## Annual Reviews {#annual-reviews}
### Journal {#annual-reviews-journal}
@@ -398,16 +414,6 @@ 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 中找到']}/>
## Scitation {#scitation}
### 期刊 {#scitation-qi-kan}
<Route author="Derekmini auto-bot-ty" example="/scitation/aapt/ajp" path="/scitation/:pub/:jrn" paramsDesc={['出版社,URL 中 `scitation.org` 前部分','期刊,URL 中 `/toc/` 后部分']} radar="1" rssbud="1" puppeteer="1"/>
### 专栏 {#scitation-zhuan-lan}
<Route author="Derekmini auto-bot-ty" example="/scitation/aapt/ajp/COMPUTATIONAL+PHYSICS" path="/scitation/:pub/:jrn/:sec" paramsDesc={['出版社,URL 中 `scitation.org` 前部分','期刊,URL 中 `/toc/` 后部分','专栏,URL 中 `tocSection` 部分']} radar="1" rssbud="1" puppeteer="1"/>
## Springer {#springer}
### 期刊 {#springer-qi-kan}
@@ -61,6 +61,22 @@ More jounals can be found in [AEA Journals](https://www.aeaweb.org/journals).
</RouteEn>
## American Institute of Physics
### Journal
<RouteEn author="Derekmini auto-bot-ty" example="/aip/aapt/ajp" path="/aip/:pub/:jrn" paramsDesc={['Publisher id','Journal id']} radar="1" rssbud="1" supportScihub="1">
Refer to the URL format `pubs.aip.org/:pub/:jrn`
:::tip Tip
More jounals can be found in [AIP Publications](https://publishing.aip.org/publications/find-the-right-journal).
:::
</RouteEn>
## Annual Reviews
### Journal
@@ -427,16 +443,6 @@ To subscribe to [IN THE PIPELINE by Derek Lowes](https://science.org/blogs/pi
<RouteEn author="nczitzk" example="/sciencedirect/journal/research-policy" path="/sciencedirect/journal/:id" paramsDesc={['Journal id, can be found in URL']}/>
## Scitation
### Journal
<RouteEn author="Derekmini auto-bot-ty" example="/scitation/aapt/ajp" path="/scitation/:pub/:jrn" paramsDesc={['Publisher, the part of the URL before `scitation.org`','Journal, the part of the URL after `/toc/`']} radar="1" rssbud="1" puppeteer="1"/>
### Section
<RouteEn author="Derekmini auto-bot-ty" example="/scitation/aapt/ajp/COMPUTATIONAL+PHYSICS" path="/scitation/:pub/:jrn/:sec" paramsDesc={['Publisher, the part of the URL before `scitation.org`','Journal, the part of the URL after `/toc/`','Section, the `tocSection` part of the URL']} radar="1" rssbud="1" puppeteer="1"/>
## Springer
### Journal