feat: add Polimi News (#2339)

This commit is contained in:
Xuanbo
2019-06-08 07:43:23 +02:00
committed by DIYgod
parent 612e30747a
commit 1c40e37f4e
3 changed files with 31 additions and 0 deletions

View File

@@ -18,6 +18,12 @@ pageClass: routes
<Route author="LogicJake" example="/mit/graduateadmissions/category/beyond-the-lab" path="/universities/mit/graduateadmissions/category/:name" :paramsDesc="['category name which can be found in url']"/>
## Polimi
### News
<Route author="exuanbo" example="/polimi/news" path="/polimi/news/:language?" :paramsDesc="['English language code en']" />
## 北京大学
### 信科公告通知

View File

@@ -1389,4 +1389,7 @@ router.get('/monsterhunter/update', require('./routes/monsterhunter/update'));
// 005.tv
router.get('/005tv/zx/latest', require('./routes/005tv/zx'));
// Polimi News
router.get('/polimi/news/:language?', require('./routes/polimi/news'));
module.exports = router;

22
lib/routes/polimi/news.js Normal file
View File

@@ -0,0 +1,22 @@
const buildData = require('@/utils/common-config');
module.exports = async (ctx) => {
let link = `https://www.polimi.it/tutte-le-news/`;
if (ctx.params.language === 'en') {
link = `https://www.polimi.it/en/all-news/`;
}
ctx.state.data = await buildData({
link,
url: link,
title: `Polimi News`,
params: {
homeLink: 'https://www.polimi.it',
},
item: {
item: '.container .no',
title: `$('h3').text()`,
link: `'%homeLink%' + $('p span a').attr('href')`,
description: `$('p').text() + '<p></p>' + '<a href="' + '%homeLink%' + $('p span a').attr('href') + '">Full Article</a'`,
},
});
};