From 94761c1109eca818f04b42a66d9b08d6e97eb0c8 Mon Sep 17 00:00:00 2001 From: Pretty9 <41198038+Pretty9@users.noreply.github.com> Date: Tue, 24 Mar 2020 10:51:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9EHNUST=E6=95=99?= =?UTF-8?q?=E5=8A=A1=E5=A4=84=E9=80=9A=E7=9F=A5=20(#4296)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/university.md | 6 ++++ lib/router.js | 3 ++ lib/routes/universities/hnust/jwc/index.js | 33 ++++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 lib/routes/universities/hnust/jwc/index.js diff --git a/docs/university.md b/docs/university.md index e054ce68b6..6178d0780f 100644 --- a/docs/university.md +++ b/docs/university.md @@ -490,6 +490,12 @@ category 列表: +## 湖南科技大学 + +### 教务处通知 + + + ## 华北水利水电大学 ### 学校通知 diff --git a/lib/router.js b/lib/router.js index 270c4b12e9..2f3d884ab7 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2410,6 +2410,9 @@ router.get('/hubu/news/:type', require('./routes/universities/hubu/news')); // 大连海事大学 router.get('/dlmu/news/:type', require('./routes/universities/dlmu/news')); +// 湖南科技大学教务处 +router.get('/hnust/jwc', require('./routes/universities/hnust/jwc/index')); + // AGE动漫 router.get('/agefans/detail/:id', require('./routes/agefans/detail')); diff --git a/lib/routes/universities/hnust/jwc/index.js b/lib/routes/universities/hnust/jwc/index.js new file mode 100644 index 0000000000..681c507e10 --- /dev/null +++ b/lib/routes/universities/hnust/jwc/index.js @@ -0,0 +1,33 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const base = 'http://jwc.hnust.edu.cn/gzzd2_20170827120536008171/jwk3_20170827120536008171/'; + const link = 'http://jwc.hnust.edu.cn/gzzd2_20170827120536008171/jwk3_20170827120536008171/index.htm'; + const response = await got.get(link); + const $ = cheerio.load(response.data); + const list = $('.articleList ul li'); + + ctx.state.data = { + title: '湖南科技大学教务处通知', + link: link, + description: '湖南科技大学教务处通知', + item: + list && + list + .map((index, item) => { + item = $(item); + const date = item.find('span').text(); + const title = item.find('a').text(); + const url = base + item.find('a').attr('href'); + + return { + title: title, + description: title, + pubDate: new Date(date).toUTCString(), + link: url, + }; + }) + .get(), + }; +};