diff --git a/docs/README.md b/docs/README.md index 19bcfd522..02ba98a8e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1662,6 +1662,16 @@ category 列表: +### 河南大学 + + + +| 学生专栏 | 教师专栏 | 新闻公告 | 院部动态 | 高教前沿 | +| -------- | -------- | -------- | -------- | -------- | +| xszl | jszl | xwgg | ybdt | gjqy | + + + ## 传统媒体 ### 央视新闻 diff --git a/router.js b/router.js index e85fff762..a08e0b03d 100644 --- a/router.js +++ b/router.js @@ -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')); diff --git a/routes/universities/henu/news.js b/routes/universities/henu/news.js new file mode 100644 index 000000000..a396d7f75 --- /dev/null +++ b/routes/universities/henu/news.js @@ -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(), + }; +};