mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat(route): add mit csail news (#7005)
This commit is contained in:
@@ -22,6 +22,10 @@ pageClass: routes
|
||||
|
||||
<RouteEn author="LogicJake" example="/mit/graduateadmissions/category/beyond-the-lab" path="/mit/graduateadmissions/category/:name" :paramsDesc="['category name which can be found in url']"/>
|
||||
|
||||
### MIT CSAIL
|
||||
|
||||
<RouteEn author="nczitzk" example="/mit/csail/news" path="/mit/csail/news"/>
|
||||
|
||||
## Polimi
|
||||
|
||||
### News
|
||||
|
||||
@@ -22,6 +22,10 @@ pageClass: routes
|
||||
|
||||
<Route author="LogicJake" example="/mit/graduateadmissions/category/beyond-the-lab" path="/mit/graduateadmissions/category/:name" :paramsDesc="['category name which can be found in url']"/>
|
||||
|
||||
### MIT CSAIL
|
||||
|
||||
<Route author="nczitzk" example="/mit/csail/news" path="/mit/csail/news"/>
|
||||
|
||||
## Polimi
|
||||
|
||||
### News
|
||||
|
||||
@@ -1683,6 +1683,7 @@ router.get('/metred/fuli', require('./routes/metred/fuli'));
|
||||
// MIT
|
||||
router.get('/mit/graduateadmissions/:type/:name', require('./routes/universities/mit/graduateadmissions'));
|
||||
router.get('/mit/ocw-top', require('./routes/universities/mit/ocw-top'));
|
||||
router.get('/mit/csail/news', require('./routes/universities/mit/csail/news'));
|
||||
|
||||
// 毕马威
|
||||
router.get('/kpmg/insights', require('./routes/kpmg/insights'));
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'https://www.csail.mit.edu';
|
||||
const currentUrl = `${rootUrl}/news`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
$('.featured-person').remove();
|
||||
|
||||
const list = $('article[role="article"]')
|
||||
.slice(0, 15)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
link: `${rootUrl}${item.attr('about')}`,
|
||||
};
|
||||
})
|
||||
.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);
|
||||
|
||||
content('.sidebar-right, .sidebar-item').remove();
|
||||
|
||||
item.title = content('.page-title').text();
|
||||
item.description = content('.content-container-inner').html();
|
||||
item.pubDate = new Date(content('time').attr('datetime')).toUTCString();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'News - MIT CSAIL',
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user