diff --git a/docs/en/journal.md b/docs/en/journal.md index 05f727b4f2..d268f1fe33 100644 --- a/docs/en/journal.md +++ b/docs/en/journal.md @@ -35,6 +35,12 @@ Fill in parameter `query` with content after `http://export.arxiv.org/api/query? +## BioOne + +### Featured articles + + + ## Cell Journal diff --git a/docs/journal.md b/docs/journal.md index 78b7111bcf..b136b90a4f 100644 --- a/docs/journal.md +++ b/docs/journal.md @@ -35,6 +35,12 @@ pageClass: routes +## BioOne + +### Featured articles + + + ## Cell ### 主刊 diff --git a/lib/router.js b/lib/router.js index 078c3792d5..666bd58896 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3926,6 +3926,9 @@ router.get('/tianyancha/hot', require('./routes/tianyancha/hot')); // King Arthur router.get('/kingarthur/:type', require('./routes/kingarthur/index')); +// BioOne +router.get('/bioone/featured', require('./routes/bioone/featured')); + // Obsidian router.get('/obsidian/announcements', require('./routes/obsidian/announcements')); diff --git a/lib/routes/bioone/featured.js b/lib/routes/bioone/featured.js new file mode 100644 index 0000000000..847f7cf732 --- /dev/null +++ b/lib/routes/bioone/featured.js @@ -0,0 +1,50 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const rootUrl = 'https://bioone.org'; + const response = await got({ + method: 'get', + url: rootUrl, + }); + + const $ = cheerio.load(response.data); + + const list = $('.items h4 a') + .slice(0, 10) + .map((_, item) => { + item = $(item); + const link = item.attr('href'); + + return { + title: item.text(), + link: link.indexOf('http') < 0 ? `${rootUrl}${link}` : link, + }; + }) + .get(); + + const items = await Promise.all( + list.map( + async (item) => + await ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + const content = cheerio.load(detailResponse.data); + + item.description = content('#divARTICLECONTENTTop').html(); + item.doi = content('meta[name="dc.Identifier"]').attr('content'); + item.pubDate = new Date(content('meta[name="dc.Date"]').attr('content')).toUTCString(); + + return item; + }) + ) + ); + + ctx.state.data = { + title: 'Featured articles - BioOne', + link: rootUrl, + item: items, + }; +};