From 5ed4cda42dad7504c9f678ccaeba98eb15326ede Mon Sep 17 00:00:00 2001 From: teapot1de <121592812+ywh555hhh@users.noreply.github.com> Date: Thu, 7 Dec 2023 10:04:36 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20=E5=8D=97=E6=98=8C?= =?UTF-8?q?=E5=A4=A7=E5=AD=A6=E6=95=99=E5=8A=A1=E5=A4=84=20(#13973)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 添加了新的RSSHub路由,支持Radar ,以及修改了对应的文档 新增了针对南昌大学教务处通知的RSSHub路由,支持Radar。 同时修改了RSShub文档 * Removed redundant settings and fixed the year. 删去了多余的代码,更正了正确的年份 --- lib/v2/ncu/jwc.js | 33 ++++++++++++++++++++++++++++++ lib/v2/ncu/maintainer.js | 3 +++ lib/v2/ncu/radar.js | 13 ++++++++++++ lib/v2/ncu/router.js | 4 ++++ website/docs/routes/university.mdx | 6 ++++++ 5 files changed, 59 insertions(+) create mode 100644 lib/v2/ncu/jwc.js create mode 100644 lib/v2/ncu/maintainer.js create mode 100644 lib/v2/ncu/radar.js create mode 100644 lib/v2/ncu/router.js diff --git a/lib/v2/ncu/jwc.js b/lib/v2/ncu/jwc.js new file mode 100644 index 0000000000..940b770bc3 --- /dev/null +++ b/lib/v2/ncu/jwc.js @@ -0,0 +1,33 @@ +const got = require('@/utils/got'); // 自订的 got +const cheerio = require('cheerio'); // 可以使用类似 jQuery 的 API HTML 解析器 +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const baseUrl = "https://jwc.ncu.edu.cn"; + const response = await got(baseUrl); + const $ = cheerio.load(response.body); + + const list = $(".box3 .inner ul.img-list li"); + + ctx.state.data = { + title: "南昌大学教务处", + link: baseUrl, + description: "南昌大学教务处", + item: + list && + list.toArray().map((item) => { + const el = $(item); + const linkEl = el.find("a"); + const date = el.text().split("】")[0].replace("【", "").trim(); + const title = linkEl.attr("title"); + const link = `${baseUrl}/${linkEl.attr("href")}`; + const month = date.slice(0, 2); + + return { + title, + link, + pubDate: parseDate(date, 'MM-DD').setFullYear(month < 6 ? new Date().getFullYear() - 1 : new Date().getFullYear()), + }; + }), + }; +}; diff --git a/lib/v2/ncu/maintainer.js b/lib/v2/ncu/maintainer.js new file mode 100644 index 0000000000..9e7dc51511 --- /dev/null +++ b/lib/v2/ncu/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/jwc': ['ywh555hhh'], +}; diff --git a/lib/v2/ncu/radar.js b/lib/v2/ncu/radar.js new file mode 100644 index 0000000000..cbac079da2 --- /dev/null +++ b/lib/v2/ncu/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'ncu.edu.cn': { + _name: '南昌大学', + '.': [ + { + title: '教务通知', + docs: 'https://docs.rsshub.app/routes/university#nan-chang-da-xue', + source: ['/', '/jwtz/index.htm'], + target: '/ncu/jwc', + }, + ], + }, +}; diff --git a/lib/v2/ncu/router.js b/lib/v2/ncu/router.js new file mode 100644 index 0000000000..34637452fb --- /dev/null +++ b/lib/v2/ncu/router.js @@ -0,0 +1,4 @@ +module.exports = function (router) { + router.get('/jwc', require('./jwc')); + +}; diff --git a/website/docs/routes/university.mdx b/website/docs/routes/university.mdx index 5bd0a49776..0d63eec046 100644 --- a/website/docs/routes/university.mdx +++ b/website/docs/routes/university.mdx @@ -2108,6 +2108,12 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS +## 南昌大学 {#nan-chang-da-xue} + +### 教务通知 {#nan-chang-da-xue--jiao-wu-tong-zhi} + + + ## 南昌航空大学 {#nan-chang-hang-kong-da-xue} ### 教务处公告与新闻 {#nan-chang-hang-kong-da-xue-jiao-wu-chu-gong-gao-yu-xin-wen}