From b8bdf9ca58decffa9e845c6aba2eb0fa10d9b23a Mon Sep 17 00:00:00 2001 From: Kimika Date: Sun, 9 Sep 2018 22:51:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=88=90=E9=83=BD=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E5=B7=A5=E7=A8=8B=E5=A4=A7=E5=AD=A6=E6=96=B0=E9=97=BB?= =?UTF-8?q?=E7=BD=91=20(#661)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 未测试,仿照江南大学东南大学的js写的,若有问题还请劳烦看看 --- docs/README.md | 16 +++++++++++++ router.js | 3 +++ routes/universities/cuit/cxxww.js | 38 +++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 routes/universities/cuit/cxxww.js diff --git a/docs/README.md b/docs/README.md index 0e610a04bf..65224795fc 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2057,6 +2057,22 @@ category 列表: 工作通知:无 +### 成都信息工程大学 + +#### 成信新闻网 + +举例: + +路由: `/cuit/cxxww/:type?` + +参数: + +- type, 可选, 默认为 `1` + +| 综合新闻 | 信息公告 | 焦点新闻 | 学术动态 | 工作交流 | +| -------- | -------- | -------- | -------- | -------- | +| 1 | 2 | 3 | 4 | 5 | + ### 重庆科技学院 #### 教务处公告 diff --git a/router.js b/router.js index 763fafc1f6..6525e1b6b2 100644 --- a/router.js +++ b/router.js @@ -506,6 +506,9 @@ router.get('/nchu/jwc/:type?', require('./routes/universities/nchu/jwc')); // 哈尔滨工程大学 router.get('/heu/ugs/news/:author?/:category?', require('./routes/universities/heu/ugs/news')); +// 成都信息工程大学 +router.get('/cuit/cxxww/:type?', require('./routes/universities/cuit/cxxww')); + // 重庆科技学院 router.get('/cqust/jw/:type?', require('./routes/universities/cqust/jw')); router.get('/cqust/lib/:type?', require('./routes/universities/cqust/lib')); diff --git a/routes/universities/cuit/cxxww.js b/routes/universities/cuit/cxxww.js new file mode 100644 index 0000000000..2fe6eeba04 --- /dev/null +++ b/routes/universities/cuit/cxxww.js @@ -0,0 +1,38 @@ +const axios = require('../../../utils/axios'); +const cheerio = require('cheerio'); +const resolve_url = require('url').resolve; + +const host = 'http://www.cuit.edu.cn/'; + +module.exports = async (ctx) => { + const type = ctx.params.type || '1'; + const link = host + 'NewsList?id=' + type; + + const response = await axios({ + method: 'get', + url: link, + headers: { + Referer: host, + }, + }); + + const $ = cheerio.load(response.data); + + ctx.state.data = { + link: link, + title: $('#NewsTypeName').text(), + item: $('.news1-links-ul>li') + .map((_, elem) => ({ + link: resolve_url(link, $('a', elem).attr('href')), + title: $('a', elem).text(), + pubDate: new Date( + $('.datetime', elem) + .text() + .replace('[', '') + .replace(']', '') + ).toUTCString(), + description: ' ', + })) + .get(), + }; +};