From fe05c0cbd985b4ade77d64316f95a59993cdb4f1 Mon Sep 17 00:00:00 2001 From: OrbitZore Date: Sun, 18 Oct 2020 10:44:41 -0500 Subject: [PATCH] =?UTF-8?q?feat:=20add=20=E6=B9=96=E5=8D=97=E7=A7=91?= =?UTF-8?q?=E6=8A=80=E5=A4=A7=E5=AD=A6=E5=8C=96=E5=AD=A6=E5=8C=96=E5=B7=A5?= =?UTF-8?q?=E5=AD=A6=E9=99=A2=E9=80=9A=E7=9F=A5=20(#5905)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/university.md | 4 +++ lib/router.js | 1 + lib/routes/universities/hnust/chem/index.js | 34 +++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 lib/routes/universities/hnust/chem/index.js diff --git a/docs/university.md b/docs/university.md index 00aea88cf..9d9923775 100644 --- a/docs/university.md +++ b/docs/university.md @@ -693,6 +693,10 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS +### 化学化工学院通知 + + + ### 艺术学院通知 diff --git a/lib/router.js b/lib/router.js index df6882aca..b7cab82c4 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2693,6 +2693,7 @@ router.get('/bityjs', require('./routes/universities/bit/bityjs')); router.get('/hnust/jwc', require('./routes/universities/hnust/jwc/index')); router.get('/hnust/computer', require('./routes/universities/hnust/computer/index')); router.get('/hnust/art', require('./routes/universities/hnust/art/index')); +router.get('/hnust/chem', require('./routes/universities/hnust/chem/index')); router.get('/hnust/graduate/:type?', require('./routes/universities/hnust/graduate/index')); // 西南交通大学 diff --git a/lib/routes/universities/hnust/chem/index.js b/lib/routes/universities/hnust/chem/index.js new file mode 100644 index 000000000..849167f60 --- /dev/null +++ b/lib/routes/universities/hnust/chem/index.js @@ -0,0 +1,34 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const base = 'http://chem.hnust.edu.cn/sytzgg/'; + const link = base + 'index.htm'; + const response = await got.get(link); + const $ = cheerio.load(response.data); + const list = $('.subNewsList li'); + + ctx.state.data = { + title: '湖南科技大学化学化工学院通知', + link: link, + description: '湖南科技大学化学化工学院通知', + image: 'https://i.loli.net/2020/03/24/EAoPzbTsBxeOdjH.jpg', + item: + list && + list + .map((index, item) => { + item = $(item); + const date = item.find('span').text(); + const title = item.find('h3').text(); + const url = base + item.find('a').attr('href'); + + return { + title: title, + description: title, + pubDate: new Date(date).toUTCString(), + link: url, + }; + }) + .get(), + }; +};