From 834b5dca56ca6ff259d87c55b92e5df6001a0ded Mon Sep 17 00:00:00 2001 From: Lava-Swimmer <58315416+Lava-Swimmer@users.noreply.github.com> Date: Mon, 13 Apr 2020 19:28:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20add=20=E6=B9=96=E5=8C=97=E5=B7=A5?= =?UTF-8?q?=E4=B8=9A=E5=A4=A7=E5=AD=A6=E8=AE=A1=E7=AE=97=E6=9C=BA=E5=AD=A6?= =?UTF-8?q?=E9=99=A2=20(#4393)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/radar-rules.js | 32 +++++++++++++++++++++++ docs/university.md | 14 ++++++++++ lib/router.js | 1 + lib/routes/universities/hbut/cs.js | 41 ++++++++++++++++++++++++++++++ 4 files changed, 88 insertions(+) create mode 100644 lib/routes/universities/hbut/cs.js diff --git a/assets/radar-rules.js b/assets/radar-rules.js index c7bad6a443..bb02a4ff33 100644 --- a/assets/radar-rules.js +++ b/assets/radar-rules.js @@ -1573,5 +1573,37 @@ }, }, ], + jsjxy: [ + { + title: '新闻动态', + docs: 'http://docs.rsshub.app/university.html#hu-bei-gong-ye-da-xue', + source: '/index/xwdt.htm', + target: '/hbut/cs/xwdt', + }, + { + title: '通知公告', + docs: 'http://docs.rsshub.app/university.html#hu-bei-gong-ye-da-xue', + source: '/index/tzgg.htm', + target: '/hbut/cs/tzgg', + }, + { + title: '教学信息', + docs: 'http://docs.rsshub.app/university.html#hu-bei-gong-ye-da-xue', + source: '/jxxx.htm', + target: '/hbut/cs/jxxx', + }, + { + title: '科研动态', + docs: 'http://docs.rsshub.app/university.html#hu-bei-gong-ye-da-xue', + source: '/kxyj/kydt.htm', + target: '/hbut/cs/kydt', + }, + { + title: '党建活动', + docs: 'http://docs.rsshub.app/university.html#hu-bei-gong-ye-da-xue', + source: '/djhd/djhd.htm', + target: '/hbut/cs/djhd', + }, + ], }, }); diff --git a/docs/university.md b/docs/university.md index b26a60b749..6f240cd287 100644 --- a/docs/university.md +++ b/docs/university.md @@ -512,6 +512,20 @@ category 列表: +### 计算机学院 + + + +| 新闻动态 | 通知公告 | 教学信息 | 科研动态 | 党建活动 | +| -------- | -------- | -------- | -------- | -------- | +| xwdt | tzgg | jxxx | kydt | djhd | + + + +::: warning 注意 +jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS_REJECT_UNAUTHORIZED = 0 +::: + ## 湖南科技大学 ### 教务处通知 diff --git a/lib/router.js b/lib/router.js index 24c723e73c..b8468ba673 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2509,5 +2509,6 @@ router.get('/blogs/diygod/gk', require('./routes/blogs/diygod/gk')); // 湖北工业大学 router.get('/hbut/news/:type', require('./routes/universities/hbut/news')); +router.get('/hbut/cs/:type', require('./routes/universities/hbut/cs')); module.exports = router; diff --git a/lib/routes/universities/hbut/cs.js b/lib/routes/universities/hbut/cs.js new file mode 100644 index 0000000000..caeaae154f --- /dev/null +++ b/lib/routes/universities/hbut/cs.js @@ -0,0 +1,41 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const resolve_url = require('url').resolve; + +const base_url = 'https://jsjxy.hbut.edu.cn'; + +const map = { + xwdt: '/index/xwdt.htm', + tzgg: '/index/tzgg.htm', + jxxx: '/jxxx.htm', + kydt: '/kxyj/kydt.htm', + djhd: '/djhd/djhd.htm', +}; + +module.exports = async (ctx) => { + const type = ctx.params.type; + const link = `${base_url}${map[type]}`; + + const response = await got({ + method: 'get', + url: link, + headers: { + Referer: link, + }, + }); + + const $ = cheerio.load(response.data); + + ctx.state.data = { + link: link, + title: $('title').text(), + item: $('dl.nesw_list>dt') + .slice(0, 10) + .map((_, elem) => ({ + link: resolve_url(link, $('a', elem).attr('href')), + title: $('a', elem).text(), + pubDate: new Date(`${$('font:nth-child(3)', elem).text()}`).toString(), + })) + .get(), + }; +};