feat(route): add Oxford Academic - Oxford University Press (#9164)

* feat(route): add Oxford Academic - Oxford University Press

* Update lib/v2/oup/index.js

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update docs/en/journal.md

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update docs/journal.md

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

Co-authored-by: Tony <TonyRL@users.noreply.github.com>
This commit is contained in:
Fatpandac 2022-02-21 23:35:06 +08:00 committed by GitHub
parent f51bfaeb0c
commit 96d7059b7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 94 additions and 0 deletions

View File

@ -237,6 +237,14 @@ Subscribe to the cover images of the Nature journals, and get the latest publica
<RouteEn author="yech1990" example="/nature/highlight" path="/nature/highlight" supportScihub="1"/>
## Oxford University Press
### Oxford Academic
#### Journal
<Route author="Fatpandac" example="/oup/journals/adaptation" path="/oup/journals/:name" :paramsDesc="['short name for a journal, can be found in URL']" anticrawler="1"/>
## Proceedings of The National Academy of Sciences (PNAS)
### Latest Articles - Articles by Topic

View File

@ -210,6 +210,14 @@ pageClass: routes
<Route author="yech1990" example="/nature/highlight" path="/nature/highlight" supportScihub="1"/>
## Oxford University Press
### Oxford Academic
#### 期刊
<Route author="Fatpandac" example="/oup/journals/adaptation" path="/oup/journals/:name" :paramsDesc="['期刊名称缩写,可以在网址中得到']" anticrawler="1"/>
## PNAS
### 最新文章(可筛选领域)

53
lib/v2/oup/index.js Normal file
View File

@ -0,0 +1,53 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const path = require('path');
const { art } = require('@/utils/render');
const rootUrl = 'https://academic.oup.com';
module.exports = async (ctx) => {
const name = ctx.params.name;
const url = `${rootUrl}/${name}/issue`;
const response = await got(url);
const cookies = response.headers['set-cookie'].map((item) => item.split(';')[0]).join(';');
const $ = cheerio.load(response.data);
const list = $('div.al-article-items')
.map((_, item) => ({
title: $(item).find('a.at-articleLink').text(),
link: new URL($(item).find('a.at-articleLink').attr('href'), rootUrl).href,
}))
.get();
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link, {
headers: {
Cookie: cookies,
},
});
const content = cheerio.load(detailResponse.data);
item.author = content('a.linked-name.js-linked-name-trigger').text();
item.description = art(path.join(__dirname, 'templates/article.art'), {
abstractContent: content('section.abstract > p.chapter-para').text(),
keywords: content('div.kwd-group > a')
.map((_, item) => $(item).text())
.get()
.join(','),
});
item.pubDate = parseDate(content('div.citation-date').text());
return item;
})
)
);
ctx.state.data = {
title: `OUP - ${name}`,
link: url,
item: items,
};
};

3
lib/v2/oup/maintainer.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = {
'/:name': ['Fatpandac'],
};

13
lib/v2/oup/radar.js Normal file
View File

@ -0,0 +1,13 @@
module.exports = {
'oup.com': {
_name: 'Oxford University Press',
academic: [
{
title: '期刊',
docs: 'https://docs.rsshub.app/journal.html#oxford-university-press',
source: ['/', '/:name/issue'],
target: '/oup/journals/:name',
},
],
},
};

3
lib/v2/oup/router.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/journals/:name', require('./index'));
};

View File

@ -0,0 +1,6 @@
<h2>Abstract</h2>
<p>{{abstractContent}}</p>
{{ if keywords }}
<h2>Keywords</h2>
<p>{{keywords}}</p>
{{ /if }}