From 99d7c0cacd2913f0b33a2eccee4d659faf67616c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Wang?= <52880665+RiverTwilight@users.noreply.github.com> Date: Sun, 2 Oct 2022 23:20:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=A5=BF=E5=8D=97?= =?UTF-8?q?=E7=9F=B3=E6=B2=B9=E5=A4=A7=E5=AD=A6=E8=B4=A2=E7=BB=8F=E5=AD=A6?= =?UTF-8?q?=E9=99=A2=E5=92=8C=E4=BF=A1=E6=81=AF=E5=AD=A6=E9=99=A2=20(#1097?= =?UTF-8?q?0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add 西南石油大学财金学院和信息学院 * add 西南石油大学财经学院和信息学院 * Merge branch 'master' of github.com:RiverTwilight/RSSHub * feat: 增加西南石油大学信息学院和财经学院 * lint: remove console-log * lint: simplify got usage, and so on * lint: parenthesize the returned value * lint: remove useless symbol * docs: fixes --- docs/university.md | 20 +++++++++++++++ lib/v2/swpu/cjxy.js | 53 +++++++++++++++++++++++++++++++++++++++ lib/v2/swpu/is.js | 53 +++++++++++++++++++++++++++++++++++++++ lib/v2/swpu/maintainer.js | 2 ++ lib/v2/swpu/radar.js | 12 +++++++++ lib/v2/swpu/router.js | 2 ++ 6 files changed, 142 insertions(+) create mode 100644 lib/v2/swpu/cjxy.js create mode 100644 lib/v2/swpu/is.js diff --git a/docs/university.md b/docs/university.md index 066129c9b5..fedeb1cb4e 100644 --- a/docs/university.md +++ b/docs/university.md @@ -2989,6 +2989,26 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS +### 财经学院 + + + +| 栏目 | 学院新闻 | 学院通知 | +| -- | ---- | ---- | +| 代码 | xyxw | xytz | + + + +### 信息学院 + + + +| 栏目 | 学院新闻 | 通知公告 | 教育教学 | 学生工作 | 招生就业 | +| -- | ---- | ---- | ---- | ---- | ---- | +| 代码 | xyxw | tzgg | jyjx | xsgz | zsjy | + + + ## 信阳师范学院 ### 高等教育自学考试办公室 diff --git a/lib/v2/swpu/cjxy.js b/lib/v2/swpu/cjxy.js new file mode 100644 index 0000000000..33ef336e0b --- /dev/null +++ b/lib/v2/swpu/cjxy.js @@ -0,0 +1,53 @@ +const { parseDate } = require('@/utils/parse-date'); +const cheerio = require('cheerio'); +const got = require('@/utils/got'); +const timezone = require('@/utils/timezone'); + +module.exports = async (ctx) => { + const url = `https://www.swpu.edu.cn/nccjxy/xydt/${ctx.params.code}.htm`; + + const res = await got(url); + const $ = cheerio.load(res.data); + + let title = $('title').text(); + title = title.substring(0, title.indexOf('-')); + + const items = $('.main_conRCb > ul > li') + .toArray() + .map((elem) => ({ + title: $('a[href]', elem).text().trim(), + pubDate: timezone(parseDate($('span', elem).text(), 'YYYY年MM月DD日'), +8), + link: `https://www.swpu.edu.cn/nccjxy/${$('a[href]', elem).attr('href').split('../')[1]}`, + })); + + const out = await Promise.all( + items.map((item) => + ctx.cache.tryGet(item.link, async () => { + const res = await got(item.link); + const $ = cheerio.load(res.data); + if ($('title').text().startsWith('系统提示')) { + item.author = '系统'; + item.description = '无权访问'; + } else { + item.author = '财经学院'; + item.description = $('.v_news_content').html(); + for (const elem of $('.v_news_content p')) { + if ($(elem).css('text-align') === 'right') { + item.author = $(elem).text(); + break; + } + } + } + return item; + }) + ) + ); + + ctx.state.data = { + title: `西南石油大学财经学院 ${title}`, + link: url, + description: `西南石油大学财经学院 ${title}`, + language: 'zh-CN', + item: out, + }; +}; diff --git a/lib/v2/swpu/is.js b/lib/v2/swpu/is.js new file mode 100644 index 0000000000..cde903df9d --- /dev/null +++ b/lib/v2/swpu/is.js @@ -0,0 +1,53 @@ +const { parseDate } = require('@/utils/parse-date'); +const cheerio = require('cheerio'); +const got = require('@/utils/got'); +const timezone = require('@/utils/timezone'); + +module.exports = async (ctx) => { + const url = `https://www.swpu.edu.cn/is/xydt/${ctx.params.code}.htm`; + + const res = await got(url); + const $ = cheerio.load(res.data); + + let title = $('title').text(); + title = title.substring(0, title.indexOf('-')); + + const items = $('tr[height="20"]') + .toArray() + .map((elem) => ({ + title: $('a[title]', elem).text().trim(), + pubDate: timezone(parseDate($('td:eq(1)', elem).text(), 'YYYY年MM月DD日'), +8), + link: `https://www.swpu.edu.cn/is/${$('a[href]', elem).attr('href').split('../')[1]}`, + })); + + const out = await Promise.all( + items.map((item) => + ctx.cache.tryGet(item.link, async () => { + const res = await got(item.link); + const $ = cheerio.load(res.data); + if ($('title').text().startsWith('系统提示')) { + item.author = '系统'; + item.description = '无权访问'; + } else { + item.author = '学院'; + item.description = $('.v_news_content').html(); + for (const elem of $('.v_news_content p')) { + if ($(elem).css('text-align') === 'right') { + item.author = $(elem).text(); + break; + } + } + } + return item; + }) + ) + ); + + ctx.state.data = { + title: `西南石油大学信息学院 ${title}`, + link: url, + description: `西南石油大学信息学院 ${title}`, + language: 'zh-CN', + item: out, + }; +}; diff --git a/lib/v2/swpu/maintainer.js b/lib/v2/swpu/maintainer.js index 3ce9c2e4bb..7e603e379e 100644 --- a/lib/v2/swpu/maintainer.js +++ b/lib/v2/swpu/maintainer.js @@ -1,6 +1,8 @@ module.exports = { '/bgw/:code': ['CYTMWIA'], + '/cjxy/:code': ['RiverTwilight'], '/dean/:code': ['CYTMWIA'], '/dxy/:code': ['CYTMWIA'], + '/is/:code': ['RiverTwilight'], '/scs/:code': ['CYTMWIA'], }; diff --git a/lib/v2/swpu/radar.js b/lib/v2/swpu/radar.js index 00b13ea650..68d2392709 100644 --- a/lib/v2/swpu/radar.js +++ b/lib/v2/swpu/radar.js @@ -26,6 +26,18 @@ module.exports = { source: ['/'], target: '', }, + { + title: '信息学院', + docs: 'https://docs.rsshub.app/university.html#xi-nan-shi-you-da-xue', + source: ['/'], + target: '', + }, + { + title: '财经学院', + docs: 'https://docs.rsshub.app/university.html#xi-nan-shi-you-da-xue', + source: ['/'], + target: '', + }, ], }, }; diff --git a/lib/v2/swpu/router.js b/lib/v2/swpu/router.js index c548310ca9..9fe26808c2 100644 --- a/lib/v2/swpu/router.js +++ b/lib/v2/swpu/router.js @@ -1,6 +1,8 @@ module.exports = function (router) { router.get('/bgw/:code', require('./bgw')); + router.get('/cjxy/:code', require('./cjxy')); router.get('/dean/:code', require('./dean')); router.get('/dxy/:code', require('./dxy')); + router.get('/is/:code', require('./is')); router.get('/scs/:code', require('./scs')); };