diff --git a/docs/en/journal.md b/docs/en/journal.md index 9cb0c18e6..190401f70 100644 --- a/docs/en/journal.md +++ b/docs/en/journal.md @@ -237,6 +237,14 @@ Subscribe to the cover images of the Nature journals, and get the latest publica +## Oxford University Press + +### Oxford Academic + +#### Journal + + + ## Proceedings of The National Academy of Sciences (PNAS) ### Latest Articles - Articles by Topic diff --git a/docs/journal.md b/docs/journal.md index 7e757b8bf..af63f42fb 100644 --- a/docs/journal.md +++ b/docs/journal.md @@ -210,6 +210,14 @@ pageClass: routes +## Oxford University Press + +### Oxford Academic + +#### 期刊 + + + ## PNAS ### 最新文章(可筛选领域) diff --git a/lib/v2/oup/index.js b/lib/v2/oup/index.js new file mode 100644 index 000000000..a8191159b --- /dev/null +++ b/lib/v2/oup/index.js @@ -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, + }; +}; diff --git a/lib/v2/oup/maintainer.js b/lib/v2/oup/maintainer.js new file mode 100644 index 000000000..571a40b9d --- /dev/null +++ b/lib/v2/oup/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/:name': ['Fatpandac'], +}; diff --git a/lib/v2/oup/radar.js b/lib/v2/oup/radar.js new file mode 100644 index 000000000..298f97b85 --- /dev/null +++ b/lib/v2/oup/radar.js @@ -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', + }, + ], + }, +}; diff --git a/lib/v2/oup/router.js b/lib/v2/oup/router.js new file mode 100644 index 000000000..6ce9aa987 --- /dev/null +++ b/lib/v2/oup/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/journals/:name', require('./index')); +}; diff --git a/lib/v2/oup/templates/article.art b/lib/v2/oup/templates/article.art new file mode 100644 index 000000000..56c9cf297 --- /dev/null +++ b/lib/v2/oup/templates/article.art @@ -0,0 +1,6 @@ +

Abstract

+

{{abstractContent}}

+{{ if keywords }} +

Keywords

+

{{keywords}}

+{{ /if }}