mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-10 15:21:59 +08:00
feat: add nature machine intelligence latest research (#3295)
This commit is contained in:
@@ -4,6 +4,12 @@ pageClass: routes
|
||||
|
||||
# 学习
|
||||
|
||||
## nature machine intelligence
|
||||
|
||||
### latest research
|
||||
|
||||
<Route author="LogicJake" example="/nature/natmachintell/research" path="/nature/natmachintell/research" />
|
||||
|
||||
## X-MOL 平台
|
||||
|
||||
### 新闻
|
||||
|
||||
@@ -1861,6 +1861,9 @@ router.get('/hatena/anonymous_diary/archive', require('./routes/hatena/anonymous
|
||||
// kaggle
|
||||
router.get('/kaggle/discussion/:forumId/:sort?', require('./routes/kaggle/discussion'));
|
||||
|
||||
// nature
|
||||
router.get('/nature/natmachintell/research', require('./routes/nature/natmachintell/research'));
|
||||
|
||||
// dlsite
|
||||
router.get('/dlsite/new/:type', require('./routes/dlsite/new'));
|
||||
|
||||
|
||||
44
lib/routes/nature/natmachintell/research.js
Normal file
44
lib/routes/nature/natmachintell/research.js
Normal file
@@ -0,0 +1,44 @@
|
||||
const cheerio = require('cheerio');
|
||||
const got = require('@/utils/got');
|
||||
const url = require('url');
|
||||
|
||||
const host = 'https://www.nature.com';
|
||||
const link = 'https://www.nature.com/natmachintell/research';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const responses = await got.get(link);
|
||||
const $ = cheerio.load(responses.data);
|
||||
|
||||
const list = $('article').get();
|
||||
|
||||
const out = await Promise.all(
|
||||
list.map(async (item) => {
|
||||
const $ = cheerio.load(item);
|
||||
const title = $('h3 a').text();
|
||||
const itemUrl = url.resolve(host, $('h3 a').attr('href'));
|
||||
|
||||
const cache = await ctx.cache.get(itemUrl);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
|
||||
const responses = await got.get(itemUrl);
|
||||
const $d = cheerio.load(responses.data);
|
||||
const description = $d('div.c-article-body').html();
|
||||
|
||||
const single = {
|
||||
title,
|
||||
link: itemUrl,
|
||||
description,
|
||||
};
|
||||
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
ctx.state.data = {
|
||||
title: 'nature > nature machine intelligence > latest research',
|
||||
link: link,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user