mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat: add mit ocw route (#5939)
Co-authored-by: dwemerx <dwemerx> Co-authored-by: Henry Wang <hi@henry.wang>
This commit is contained in:
co-authored by
dwemerx
Henry Wang
parent
3f549e1c4d
commit
8ab858c049
@@ -6,6 +6,10 @@ pageClass: routes
|
||||
|
||||
## MIT
|
||||
|
||||
### MIT OCW Most popular courses of the month
|
||||
|
||||
<RouteEn author="dwemerx" example="/mit/ocw-top" path="/mit/ocw-top"/>
|
||||
|
||||
### MIT graduateadmissions's all blogs
|
||||
|
||||
<RouteEn author="LogicJake" example="/mit/graduateadmissions/index/all" path="/mit/graduateadmissions/index/all"/>
|
||||
|
||||
@@ -6,6 +6,10 @@ pageClass: routes
|
||||
|
||||
## MIT
|
||||
|
||||
### MIT OCW 每月热门课程
|
||||
|
||||
<Route author="dwemerx" example="/mit/ocw-top" path="/mit/ocw-top"/>
|
||||
|
||||
### MIT graduateadmissions's all blogs
|
||||
|
||||
<Route author="LogicJake" example="/mit/graduateadmissions/index/all" path="/mit/graduateadmissions/index/all"/>
|
||||
|
||||
@@ -1608,6 +1608,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('/kpmg/insights', require('./routes/kpmg/insights'));
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const link = 'https://ocw.mit.edu/courses/most-visited-courses/';
|
||||
|
||||
const getHTML = async () => {
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: link,
|
||||
});
|
||||
|
||||
return response.data;
|
||||
};
|
||||
|
||||
const html = await ctx.cache.tryGet(link, getHTML);
|
||||
const courses = [];
|
||||
|
||||
const $ = cheerio.load(html);
|
||||
$('.courseList tbody')
|
||||
.children()
|
||||
.each(function () {
|
||||
const course = {
|
||||
title: $('td', this).eq(1).text(),
|
||||
link: `https://ocw.mit.edu${$('td a', this).eq(1).attr('href')}`,
|
||||
description: $('td', this).eq(2).text(),
|
||||
};
|
||||
|
||||
courses.push(course);
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'MIT OCW top courses of the month',
|
||||
link,
|
||||
description: 'Most visited courses based on the site traffic of the previous month',
|
||||
language: 'en-us',
|
||||
item: courses,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user