From bc92dbcdc2a33ff686c2d6c2a325664c89a60504 Mon Sep 17 00:00:00 2001 From: Ethan Shen <42264778+nczitzk@users.noreply.github.com> Date: Mon, 25 Apr 2022 20:56:47 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20=E4=B8=AD=E5=8D=97?= =?UTF-8?q?=E8=B4=A2=E7=BB=8F=E6=94=BF=E6=B3=95=E5=A4=A7=E5=AD=A6=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E5=85=AC=E5=91=8A=20(#9616)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/university.md | 6 +++++ lib/v2/zuel/maintainer.js | 3 +++ lib/v2/zuel/notice.js | 52 +++++++++++++++++++++++++++++++++++++++ lib/v2/zuel/radar.js | 13 ++++++++++ lib/v2/zuel/router.js | 3 +++ 5 files changed, 77 insertions(+) create mode 100644 lib/v2/zuel/maintainer.js create mode 100644 lib/v2/zuel/notice.js create mode 100644 lib/v2/zuel/radar.js create mode 100644 lib/v2/zuel/router.js diff --git a/docs/university.md b/docs/university.md index 2d712fb21..0342b4966 100644 --- a/docs/university.md +++ b/docs/university.md @@ -3120,6 +3120,12 @@ type 列表: +## 中南财经政法大学 + +### 通知公告 + + + ## 中南大学 ### 招聘信息 diff --git a/lib/v2/zuel/maintainer.js b/lib/v2/zuel/maintainer.js new file mode 100644 index 000000000..70ac94063 --- /dev/null +++ b/lib/v2/zuel/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/notice': ['nczitzk'], +}; diff --git a/lib/v2/zuel/notice.js b/lib/v2/zuel/notice.js new file mode 100644 index 000000000..0daf7f7ac --- /dev/null +++ b/lib/v2/zuel/notice.js @@ -0,0 +1,52 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const rootUrl = 'http://wap.zuel.edu.cn'; + const currentUrl = `${rootUrl}/notice/list.htm`; + + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + let items = $('.list_item') + .toArray() + .map((item) => { + item = $(item); + + const a = item.find('.Article_Title a'); + + return { + title: a.text(), + pubDate: parseDate(item.find('.Article_PublishDate').text()), + link: `${/^http/.test(a.attr('href')) ? '' : rootUrl}${a.attr('href')}`, + }; + }); + + items = await Promise.all( + items.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + + const content = cheerio.load(detailResponse.data); + + item.description = content('.wp_articlecontent, .psgCont, .infodetail').html(); + + return item; + }) + ) + ); + + ctx.state.data = { + title: '中南财经大学 - 通知公告', + link: currentUrl, + item: items, + }; +}; diff --git a/lib/v2/zuel/radar.js b/lib/v2/zuel/radar.js new file mode 100644 index 000000000..646983342 --- /dev/null +++ b/lib/v2/zuel/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'zuel.edu.cn': { + _name: '中南财经政法大学', + wap: [ + { + title: '通知公告', + docs: 'https://docs.rsshub.app/univeristy.html#zhong-nan-cai-jing-zheng-fa-da-xue-tong-zhi-gong-gao', + source: ['/', '/notice/list.htm'], + target: '/zuel/notice', + }, + ], + }, +}; diff --git a/lib/v2/zuel/router.js b/lib/v2/zuel/router.js new file mode 100644 index 000000000..f3ac4a559 --- /dev/null +++ b/lib/v2/zuel/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/notice', require('./notice')); +};