From c13e55a4ff6a1317875d1247d65a447e8c83e6db Mon Sep 17 00:00:00 2001 From: yonvenne <32392875+yonvenne@users.noreply.github.com> Date: Wed, 9 Oct 2019 11:09:01 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20=E5=A2=9E=E5=8A=A0=E6=B5=99=E5=A4=A7?= =?UTF-8?q?=E8=BD=AF=E4=BB=B6=E5=AD=A6=E9=99=A2=E9=80=9A=E7=9F=A5=20(#3166?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/university.md | 16 ++++-- lib/router.js | 1 + lib/routes/universities/zju/cst/index.js | 63 ++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 lib/routes/universities/zju/cst/index.js diff --git a/docs/university.md b/docs/university.md index 68b1b433e6..d800979a06 100644 --- a/docs/university.md +++ b/docs/university.md @@ -957,7 +957,7 @@ https://rsshub.app/**nuist**/`bulletin` 或 https://rsshub.app/**nuist**/`bullet ### 浙大研究生院 - + | 全部公告 | 教学管理 | 各类资助 | 学科建设 | 海外交流 | | -------- | -------- | -------- | -------- | -------- | @@ -967,7 +967,7 @@ https://rsshub.app/**nuist**/`bulletin` 或 https://rsshub.app/**nuist**/`bullet ### 浙大就业服务平台 - + | 新闻动态 | 活动通知 | 学院通知 | 告示通知 | | -------- | -------- | -------- | -------- | @@ -977,7 +977,7 @@ https://rsshub.app/**nuist**/`bulletin` 或 https://rsshub.app/**nuist**/`bullet ### 浙大物理系 - + | 本系动态 | 科研通知 | 研究生教育最新消息 | 学生思政最新消息 | 研究生思政消息公告 | 研究生奖助学金 | 研究生思政就业信息 | 本科生思政消息公告 | 本科生奖助学金 | 本科生就业信息 | 学术报告 | | -------- | -------- | ------------------ | ---------------- | ------------------ | -------------- | ------------------ | ------------------ | -------------- | -------------- | -------- | @@ -985,6 +985,16 @@ https://rsshub.app/**nuist**/`bulletin` 或 https://rsshub.app/**nuist**/`bullet +### 浙大软件学院 + + + +| 全部通知 | 招生信息 | 教学管理 | 思政工作 | 实习就业 | 合作科研 | +| -------- | -------- | -------- | -------- | -------- | -------- | +| 0 | 1 | 2 | 3 | 4 | 5 | + + + ## 浙江工商大学 ### 浙江工商大学 diff --git a/lib/router.js b/lib/router.js index eaee47d123..9a97aa0e01 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1242,6 +1242,7 @@ router.get('/zju/list/:type', require('./routes/universities/zju/list')); router.get('/zju/physics/:type', require('./routes/universities/zju/physics')); router.get('/zju/grs/:type', require('./routes/universities/zju/grs')); router.get('/zju/career/:type', require('./routes/universities/zju/career')); +router.get('/zju/cst/:type', require('./routes/universities/zju/cst')); // Infoq router.get('/infoq/recommend', require('./routes/infoq/recommend')); diff --git a/lib/routes/universities/zju/cst/index.js b/lib/routes/universities/zju/cst/index.js new file mode 100644 index 0000000000..f846c877e0 --- /dev/null +++ b/lib/routes/universities/zju/cst/index.js @@ -0,0 +1,63 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +const host = 'http://www.cst.zju.edu.cn/index.php?c=Index&a=tlist&catid='; + +const map = new Map([ + [1, { id: '2', title: '浙大软件学院-招生信息' }], + [2, { id: '3', title: '浙大软件学院-教学管理' }], + [3, { id: '4', title: '浙大软件学院-思政工作' }], + [4, { id: '6', title: '浙大软件学院-实习就业' }], + [5, { id: '7', title: '浙大软件学院-合作科研' }], +]); + +async function getPage(id) { + const res = await got({ + method: 'get', + url: host + `${id}`, + }); + + const $ = cheerio.load(res.data); + const list = $('.lm_new').find('li'); + + return ( + list && + list + .map((index, item) => { + item = $(item); + return { + title: item.find('a').text(), + pubDate: new Date(item.find('.fr').text()).toUTCString(), + link: `http://cst.zju.edu.cn/${item.find('a').attr('href')}`, + }; + }) + .get() + ); +} + +module.exports = async (ctx) => { + const type = Number.parseInt(ctx.params.type); + if (type === 0) { + const tasks = []; + for (const value of map.values()) { + tasks.push(getPage(value.id)); + } + const results = await Promise.all(tasks); + let items = []; + results.forEach((result) => { + items = items.concat(result); + }); + ctx.state.data = { + title: '浙大软件学院-全部通知', + link: host + 'NULL', + item: items, + }; + } else { + const id = map.get(type).id; + ctx.state.data = { + title: map.get(type).title, + link: host + `${id}`, + item: await getPage(id), + }; + } +};