From 945d7c03edea8e8942f1a1fa78b1e9abd192805a Mon Sep 17 00:00:00 2001 From: Ethan Shen Date: Wed, 3 Mar 2021 05:44:19 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20=E5=90=89=E6=9E=97?= =?UTF-8?q?=E5=B7=A5=E5=95=86=E5=AD=A6=E9=99=A2=E6=95=99=E5=8A=A1=E5=A4=84?= =?UTF-8?q?=20(#7062)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/university.md | 10 ++++++ lib/router.js | 1 + lib/routes/universities/jlbtc/jwc.js | 50 ++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 lib/routes/universities/jlbtc/jwc.js diff --git a/docs/university.md b/docs/university.md index 0e69dbb12..e38004ef6 100644 --- a/docs/university.md +++ b/docs/university.md @@ -913,6 +913,16 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS +### 教务处 + + + +| 教务新闻 | 通知公告 | 教务工作 | 教师发展工作 | 学籍考务工作 | 教学基本建设 | +| -------- | -------- | -------- | ------------ | ------------ | ------------ | +| 1888 | 1887 | 1947 | 1949 | 2011 | 1948 | + + + ## 暨南大学 ## 暨南要闻 diff --git a/lib/router.js b/lib/router.js index 8b853930c..5f20b21fe 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3947,6 +3947,7 @@ router.get('/obsidian/announcements', require('./routes/obsidian/announcements') // 吉林工商学院 router.get('/jlbtc/kyc/:category?', require('./routes/universities/jlbtc/kyc')); +router.get('/jlbtc/jwc/:id?', require('./routes/universities/jlbtc/jwc')); router.get('/jlbtc/:category?', require('./routes/universities/jlbtc/index')); // DT 财经 diff --git a/lib/routes/universities/jlbtc/jwc.js b/lib/routes/universities/jlbtc/jwc.js new file mode 100644 index 000000000..d3152cc5e --- /dev/null +++ b/lib/routes/universities/jlbtc/jwc.js @@ -0,0 +1,50 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const id = ctx.params.id || '1887'; + + const rootUrl = 'http://jwc1.jlbtc.edu.cn'; + const currentUrl = `${rootUrl}/wejlist.jsp?urltype=tree.TreeTempUrl&wbtreeid=${id}`; + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + const list = $('.c2173') + .slice(0, 10) + .map((_, item) => { + item = $(item); + return { + title: item.text(), + link: `${rootUrl}/${item.attr('href')}`, + }; + }) + .get(); + + const items = await Promise.all( + list.map( + async (item) => + await ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + const content = cheerio.load(detailResponse.data); + + item.description = content('#vsb_content').html(); + item.pubDate = new Date(content('.timestyle2172').text()).toUTCString(); + + return item; + }) + ) + ); + + ctx.state.data = { + title: $('title').text(), + link: currentUrl, + item: items, + }; +};