feat: add fields medal (#6467)

This commit is contained in:
Ethan Shen
2020-12-18 16:57:44 +00:00
committed by GitHub
parent 4e2b1fa38c
commit 664ca6cd11
4 changed files with 53 additions and 0 deletions
+6
View File
@@ -158,6 +158,12 @@ Provides a better reading experience (full text articles) over the official one.
</RouteEn>
## International Mathematical Union
### Fields Medal
<RouteEn author="nczitzk" example="/mathunion/fields-medal" path="/mathunion/fields-medal"/>
## Letterboxd
### User diary
+6
View File
@@ -1033,6 +1033,12 @@ others = 热点新闻 + 滚动新闻
</Route>
## 国际数学联合会
### 菲尔兹奖
<Route author="nczitzk" example="/mathunion/fields-medal" path="/mathunion/fields-medal"/>
## 果壳网
### 科学人
+3
View File
@@ -3718,6 +3718,9 @@ router.get('/interesting-sky/astronomical_events/:year?', require('./routes/inte
router.get('/interesting-sky/recent-interesting', require('./routes/interesting-sky/recent-interesting'));
router.get('/interesting-sky', require('./routes/interesting-sky/index'));
// 国际数学联合会
router.get('/mathunion/fields-medal', require('./routes/mathunion/fields-medal'));
// ACM
router.get('/acm/amturingaward', require('./routes/acm/amturingaward'));
+38
View File
@@ -0,0 +1,38 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const rootUrl = 'https://www.mathunion.org';
const currentUrl = `${rootUrl}/imu-awards/fields-medal`;
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
const items = $('div.main-section')
.eq(2)
.find('.list__group')
.map((_, item) => {
item = $(item);
const year = item.find('h3').text();
const detailUrl = item.find('ul li a').attr('href');
item.find('h3, ul').remove();
return {
title: year,
link: detailUrl || currentUrl,
description: `<ul>${item.html()}</ul>`,
pubDate: new Date(`${year}-12-31`).toUTCString(),
};
})
.get();
ctx.state.data = {
title: $('title').text(),
link: currentUrl,
item: items,
};
};