mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-05 20:27:52 +08:00
feat(route): add bioone featured articles (#6990)
Co-authored-by: NeverBehave <gayhub@never.pet>
This commit is contained in:
@@ -35,6 +35,12 @@ Fill in parameter `query` with content after `http://export.arxiv.org/api/query?
|
||||
|
||||
</RouteEn>
|
||||
|
||||
## BioOne
|
||||
|
||||
### Featured articles
|
||||
|
||||
<RouteEn author="nczitzk" example="/bioone/featured" path="/bioone/featured"/>
|
||||
|
||||
## Cell Journal
|
||||
|
||||
<RouteEn author="yech1990" example="/cell/cell/current" path="/cell/cell/:category" supportScihub="1" />
|
||||
|
||||
@@ -35,6 +35,12 @@ pageClass: routes
|
||||
|
||||
</Route>
|
||||
|
||||
## BioOne
|
||||
|
||||
### Featured articles
|
||||
|
||||
<Route author="nczitzk" example="/bioone/featured" path="/bioone/featured"/>
|
||||
|
||||
## Cell
|
||||
|
||||
### 主刊
|
||||
|
||||
@@ -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'));
|
||||
|
||||
|
||||
50
lib/routes/bioone/featured.js
Normal file
50
lib/routes/bioone/featured.js
Normal file
@@ -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,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user