From f1d9029dda1f194d5cac19a5cff52d11ebbb605d Mon Sep 17 00:00:00 2001 From: Mou Wang <1325200471@qq.com> Date: Wed, 12 Dec 2018 10:52:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B2=B3=E5=8D=97=E5=A4=A7?= =?UTF-8?q?=E5=AD=A6=E6=95=99=E5=8A=A1=E5=A4=84=20(#1265)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/README.md | 10 +++++++++ router.js | 3 +++ routes/universities/henu/news.js | 38 ++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 routes/universities/henu/news.js 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(), + }; +};