From c105ab9a19a516f4677babfb373c1412fabf4830 Mon Sep 17 00:00:00 2001 From: XR-Y <62197633+XR-Y@users.noreply.github.com> Date: Mon, 25 Jul 2022 00:23:40 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20=E5=8D=97=E4=BA=AC?= =?UTF-8?q?=E5=A4=A7=E5=AD=A6=E5=9F=BA=E5=BB=BA=E5=A4=84/=E6=9C=AC?= =?UTF-8?q?=E7=A7=91=E8=BF=8E=E6=96=B0=20(#10305)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(route): add 南京大学基建处/本科迎新 * feat(route): add 南京大学基建处/本科迎新 * fix: sort router --- docs/university.md | 8 ++++++++ lib/v2/nju/admission.js | 41 +++++++++++++++++++++++++++++++++++++++ lib/v2/nju/jjc.js | 41 +++++++++++++++++++++++++++++++++++++++ lib/v2/nju/maintainer.js | 6 ++++-- lib/v2/nju/radar.js | 42 +++++++++++++++++++++++++++------------- lib/v2/nju/router.js | 4 +++- 6 files changed, 126 insertions(+), 16 deletions(-) create mode 100644 lib/v2/nju/admission.js create mode 100644 lib/v2/nju/jjc.js diff --git a/docs/university.md b/docs/university.md index d8cf970cef..5759d242ea 100644 --- a/docs/university.md +++ b/docs/university.md @@ -1721,6 +1721,14 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS +### 基建处 + + + +### 本科迎新 + + + ## 南京工程学院 ### 南京工程学院通知公告 diff --git a/lib/v2/nju/admission.js b/lib/v2/nju/admission.js new file mode 100644 index 0000000000..6b9664d393 --- /dev/null +++ b/lib/v2/nju/admission.js @@ -0,0 +1,41 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const category_dict = { + tzgg: '通知公告' + }; + + const items = await Promise.all( + Object.keys(category_dict).map(async () => { + const response = await got(`https://admission.nju.edu.cn/tzgg`); + + const data = response.data; + const $ = cheerio.load(data); + let script = $('ul').find('script'); + script = script['1'].children[0].data; + + const start = script.indexOf('['); + const end = script.lastIndexOf(']'); + const t = JSON.parse(script.substring(start, end + 1)); + + // only read first page + return Promise.resolve( + t[0].infolist.map((item) => ({ + title: item.title, + description: item.summary, + link: item.url, + author: item.username, + pubDate: parseDate(item.releasetime, 'x'), + })) + ); + }) + ); + + ctx.state.data = { + title: '本科迎新-通知公告', + link: 'https://admission.nju.edu.cn/tzgg', + item: items[0], + }; +}; diff --git a/lib/v2/nju/jjc.js b/lib/v2/nju/jjc.js new file mode 100644 index 0000000000..36e03fafac --- /dev/null +++ b/lib/v2/nju/jjc.js @@ -0,0 +1,41 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require("@/utils/timezone"); + +module.exports = async (ctx) => { + const category_dict = { + cgxx: '采购信息', + cjgg: '成交公告', + cfgg: '处罚公告', + }; + + const items = await Promise.all( + Object.keys(category_dict).map(async (c) => { + const response = await got(`https://jjc.nju.edu.cn/${c}/list.htm`); + + const data = response.data; + const $ = cheerio.load(data); + const list = $('#wp_news_w6').children().children().children(); + + // only read first page + return Promise.resolve( + list.map((index, item) => { + item = $(item); + return { + title: item.find('a').attr('title'), + description: item.find('a').first().text(), + link: 'https://jjc.nju.edu.cn' + item.find('a').attr('href'), + pubDate: timezone(parseDate(item.find('td').last().text(), 'YYYY-MM-DD'), +8), + category: category_dict[c], + };}) + ); + }) + ); + + ctx.state.data = { + title: `南京大学基建处`, + link: 'https://jjc.nju.edu.cn/main.htm', + item: [...items[0], ...items[1], ...items[2]], + }; +}; diff --git a/lib/v2/nju/maintainer.js b/lib/v2/nju/maintainer.js index 7f255f0000..fa0d80788d 100644 --- a/lib/v2/nju/maintainer.js +++ b/lib/v2/nju/maintainer.js @@ -1,8 +1,10 @@ module.exports = { - '/jw/:type': ['ret-1'], + '/admission': ['ret-1'], '/gra': ['ret-1'], + '/jjc': ['ret-1'], + '/jw/:type': ['ret-1'], '/rczp/:type': ['ret-1'], '/scit/:type': ['ret-1'], - '/zcc': ['ret-1'], '/zbb/:type': ['ret-1'], + '/zcc': ['ret-1'], }; diff --git a/lib/v2/nju/radar.js b/lib/v2/nju/radar.js index 0ecc380cdf..8a86fc65b8 100644 --- a/lib/v2/nju/radar.js +++ b/lib/v2/nju/radar.js @@ -1,12 +1,12 @@ module.exports = { 'nju.edu.cn': { _name: '南京大学', - jw: [ + admission: [ { - title: '本科生院', - docs: 'https://docs.rsshub.app/university.html#nan-jing-da-xue-ben-ke-sheng-yuan', - source: ['/'], - target: '/nju/jw/:type', + title: '本科迎新', + docs: 'https://docs.rsshub.app/university.html#nan-jing-da-xue-ben-ke-ying-xin', + source: ['/tzgg/index.html', '/'], + target: '/nju/admission', }, ], grawww: [ @@ -17,6 +17,22 @@ module.exports = { target: '/nju/gra', }, ], + jjc: [ + { + title: '基建处', + docs: 'https://docs.rsshub.app/university.html#nan-jing-da-xue-ji-jian-chu', + source: ['/main.htm', '/'], + target: '/nju/jjc', + }, + ], + jw: [ + { + title: '本科生院', + docs: 'https://docs.rsshub.app/university.html#nan-jing-da-xue-ben-ke-sheng-yuan', + source: ['/'], + target: '/nju/jw/:type', + }, + ], rczp: [ { title: '人才招聘网', @@ -33,14 +49,6 @@ module.exports = { target: '/nju/scit/:type', }, ], - zcc: [ - { - title: '资产管理处', - docs: 'https://docs.rsshub.app/university.html#nan-jing-da-xue-zi-chan-guan-li-chu', - source: ['/'], - target: '/nju/zcc', - }, - ], zbb: [ { title: '招标办公室', @@ -49,5 +57,13 @@ module.exports = { target: '/nju/zbb/:type', }, ], + zcc: [ + { + title: '资产管理处', + docs: 'https://docs.rsshub.app/university.html#nan-jing-da-xue-zi-chan-guan-li-chu', + source: ['/'], + target: '/nju/zcc', + }, + ], }, }; diff --git a/lib/v2/nju/router.js b/lib/v2/nju/router.js index a9729a22fb..202e83231e 100644 --- a/lib/v2/nju/router.js +++ b/lib/v2/nju/router.js @@ -1,8 +1,10 @@ module.exports = function (router) { + router.get('/admission', require('./admission')); + router.get('/jjc', require('./jjc')); router.get('/jw/:type', require('./jw')); router.get('/gra', require('./gra')); router.get('/rczp/:type', require('./rczp')); router.get('/scit/:type', require('./scit')); - router.get('/zcc', require('./zcc')); router.get('/zbb/:type', require('./zbb')); + router.get('/zcc', require('./zcc')); };