添加河南大学教务处 (#1265)

This commit is contained in:
Mou Wang 2018-12-12 10:52:37 +08:00 committed by DIYgod
parent a1e8632d1f
commit f1d9029dda
3 changed files with 51 additions and 0 deletions

View File

@ -1662,6 +1662,16 @@ category 列表:
</route>
### 河南大学
<route name="河南大学" author="CasterWx" example="/henu/xszl" path="/henu/:type" :paramsDesc="['分类, 见下表']">
| 学生专栏 | 教师专栏 | 新闻公告 | 院部动态 | 高教前沿 |
| -------- | -------- | -------- | -------- | -------- |
| xszl | jszl | xwgg | ybdt | gjqy |
</route>
## 传统媒体
### 央视新闻

View File

@ -654,6 +654,9 @@ router.get('/scut/jwc/:category?', require('./routes/universities/scut/jwc'));
// 温州商学院
router.get('/wzbc/:type?', require('./routes/universities/wzbc/news'));
// 河南大学
router.get('/henu/:type?', require('./routes/universities/henu/news'));
// ifanr
router.get('/ifanr/:channel?', require('./routes/ifanr/index'));

View File

@ -0,0 +1,38 @@
const axios = require('../../../utils/axios');
const cheerio = require('cheerio');
const resolve_url = require('url').resolve;
const base_url = 'http://jwc.henu.edu.cn';
const map = {
all: '/',
xszl: '/jwzl/xszl.htm',
jszl: '/jwzl/jszl.htm',
xwgg: '/jwzl/xwgg.htm',
ybdt: '/jwzl/ybdt.htm',
gjqy: '/jwzl/gjqy.htm',
};
module.exports = async (ctx) => {
const type = ctx.params.type || 'all';
const link = `${base_url}${map[type]}`;
const response = await axios({
method: 'get',
url: link,
headers: {
Referer: link,
},
});
const $ = cheerio.load(response.data);
ctx.state.data = {
link: link,
title: $('title').text(),
item: $('.list>tr')
.map((_, elem) => ({
link: resolve_url(link, $('a', elem).attr('href')),
title: $('tit1', elem).text(),
pubDate: new Date($('time1.span', elem).text()).toUTCString(),
}))
.get(),
};
};