Skip to content

Commit

Permalink
修改理工大教师通知的链接和日期 (DIYgod#905)
Browse files Browse the repository at this point in the history
  • Loading branch information
MilkShakeYoung authored and DIYgod committed Oct 17, 2018
1 parent 143862e commit 142889d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,10 @@ category 列表:

</route>

### 南京理工大学

<route name="南京理工大学教务处通知" author="MilkShakeYoung" example="/njust/jwc" path="/universities/njust/jwc"/>

### 四川旅游学院

<route name="信息与工程学院动态公告" author="talenHuang" example="/sctu/xgxy" path="/universities/sctu/xgxy"/>
Expand Down
3 changes: 3 additions & 0 deletions router.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,9 @@ router.get('/cqust/lib/:type?', require('./routes/universities/cqust/lib'));
router.get('/cczu/jwc/:category?', require('./routes/universities/cczu/jwc'));
router.get('/cczu/news/:category?', require('./routes/universities/cczu/news'));

// 南京理工大学
router.get('/njust', require('./routes/universities/njust/jwc'));

// 四川旅游学院
router.get('/sctu/xgxy', require('./routes/universities/sctu/xgxy'));
router.get('/sctu/jwc/:type?', require('./routes/universities/sctu/jwc'));
Expand Down
36 changes: 36 additions & 0 deletions routes/universities/njust/jwc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const axios = require('../../../utils/axios');
const cheerio = require('cheerio');

module.exports = async (ctx) => {
const baseURL = 'http://jwc.njust.edu.cn';
const res = await axios({
method: 'get',
url: 'http://jwc.njust.edu.cn/1216/list.htm',
headers: {
Referer: 'https://jwc.njust.edu.cn',
},
});
const data = res.data;
const $ = cheerio.load(data);
const list = $('tr', 'table#newslist');

ctx.state.data = {
title: '南京理工大学教务处',
link: 'http://jwc.njust.edu.cn/1216/list.htm',
description: '教师通知',

item:
list &&
list
.map((index, item) => {
item = $(item);

return {
title: item.find('a').text(),
link: `${baseURL + $(item.find('a')).attr('href')}`,
pubDate: new Date(item.find('td[width="14%"]').text()).toUTCString(),
};
})
.get(),
};
};

0 comments on commit 142889d

Please sign in to comment.