From 4b0807f99568020527ce35bec1e3b6842d95c4ad Mon Sep 17 00:00:00 2001 From: niuyi <30387148+niuyi1017@users.noreply.github.com> Date: Thu, 30 Mar 2023 15:59:20 +0800 Subject: [PATCH] feat(route): add /ustb/yzxc/tzgg (#12192) * feat(route): add /ustb/yzxc/tzgg * udapte /ustb/yzxc/tzgg docs etc * fix: Incomplete string escaping or encoding * fix: Incomplete string escaping or encoding * fix: Incomplete string escaping or encoding * Update lib/v2/ustb/yzxc/tzgg.js --------- --- docs/university.md | 24 +++++++++++-------- lib/v2/ustb/maintainer.js | 1 + lib/v2/ustb/radar.js | 8 +++++++ lib/v2/ustb/router.js | 1 + lib/v2/ustb/yzxc/tzgg.js | 49 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 73 insertions(+), 10 deletions(-) create mode 100644 lib/v2/ustb/yzxc/tzgg.js diff --git a/docs/university.md b/docs/university.md index 204ab8968..e7f0d1655 100644 --- a/docs/university.md +++ b/docs/university.md @@ -234,6 +234,10 @@ pageClass: routes +### 研究生招生信息网 + + + ### 北京科技大学天津学院 @@ -605,7 +609,7 @@ pageClass: routes | 博士研究生 | 硕士研究生 | 同等学力攻读硕士学位 | 港澳台地区招生 | | :--------: | :--------: | :------------------: | :------------: | -| bsyjs | ssyjs | tdxlgdssxw | gatdqzs | +| bsyjs | ssyjs | tdxlgdssxw | gatdqzs | @@ -1195,7 +1199,7 @@ category 列表: | 通知公告 | 新闻动态 | 学籍注册 | 奖助学金 | 其他 | | :------: | :------: | :------: | :------: | :--: | -| 2981 | 2980 | 3009 | 3011 | ... | +| 2981 | 2980 | 3009 | 3011 | ... | @@ -1227,7 +1231,7 @@ category 列表: | 新闻 | 新闻 - 要闻 | 新闻 - 专题策划 | 其他 | | :------: | :---------: | :-------------: | :--: | -| /card/xw | /list/xw/yw | /card/xw/ztch | ... | +| /card/xw | /list/xw/yw | /card/xw/ztch | ... | @@ -1237,7 +1241,7 @@ category 列表: | 新闻动态 | 通知公告 | 其他 | | :------: | :------: | :--: | -| 3751 | 3752 | ... | +| 3751 | 3752 | ... | @@ -2278,7 +2282,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS | 通知公告 | 本科生教务 | 研究生教务 | | :------: | :--------: | :--------: | -| tzgg | bksjw | yjsjw | +| tzgg | bksjw | yjsjw | @@ -2668,7 +2672,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS | 聚焦天大 | 综合新闻 | 校内新闻 | 媒体报道 | 图说天大 | | :------: | :------: | :------: | :------: | :------: | -| focus | general | internal | media | picture | +| focus | general | internal | media | picture | @@ -2678,7 +2682,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS | 学部新闻 | 通知公告 | 北洋智算论坛 | | :------: | :----------: | :----------: | -| news | notification | forum | +| news | notification | forum | @@ -2698,7 +2702,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS | 校级公告 | 统考硕士 | 统考博士 | 在职学位 | | :------: | :------: | :------: | :------: | -| notice | master | doctor | job | +| notice | master | doctor | job | @@ -2746,7 +2750,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS | 温大新闻 | 媒体温大 | 学术温大 | 通知公告 | 招标信息 | 学术公告 | | :------: | :------: | :------: | :------: | :------: | :------: | -| 0 | 1 | 2 | 3 | 4 | 5 | +| 0 | 1 | 2 | 3 | 4 | 5 | @@ -3551,7 +3555,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS | 招聘类型 | 博士后 | 课题项目聘用 | 管理支撑人才 | 教学科研人才 | | :------: | :----: | :----------: | :----------: | :----------: | -| 参数 | bsh | ktxmpy | glzcrc | jxkyrc | +| 参数 | bsh | ktxmpy | glzcrc | jxkyrc | diff --git a/lib/v2/ustb/maintainer.js b/lib/v2/ustb/maintainer.js index 381e67575..b6f2c6c82 100644 --- a/lib/v2/ustb/maintainer.js +++ b/lib/v2/ustb/maintainer.js @@ -21,4 +21,5 @@ module.exports = { '/yjsy/news/skl': ['DA1Y1'], '/yjsy/news/slam': ['DA1Y1'], '/yjsy/news/wenfa': ['DA1Y1'], + '/yzxc/tzgg': ['yanbot-team'], }; diff --git a/lib/v2/ustb/radar.js b/lib/v2/ustb/radar.js index 16061eb1e..720ad6a03 100644 --- a/lib/v2/ustb/radar.js +++ b/lib/v2/ustb/radar.js @@ -9,5 +9,13 @@ module.exports = { target: '/ustb/yjsy/news/:type', }, ], + yzxc: [ + { + title: '研究生招生信息网', + docs: 'https://docs.rsshub.app/university.html#bei-jing-ke-ji-da-xue-yan-jiu-sheng-zhao-sheng-xin-xi-wang', + source: '/', + target: '/ustb/yzxc/tzgg', + }, + ], }, }; diff --git a/lib/v2/ustb/router.js b/lib/v2/ustb/router.js index 4c5b8e397..add101ef3 100644 --- a/lib/v2/ustb/router.js +++ b/lib/v2/ustb/router.js @@ -1,3 +1,4 @@ module.exports = function (router) { router.get('/yjsy/news/:type', require('./yjsy/news')); + router.get('/yzxc/tzgg', require('./yzxc/tzgg')); }; diff --git a/lib/v2/ustb/yzxc/tzgg.js b/lib/v2/ustb/yzxc/tzgg.js new file mode 100644 index 000000000..e4c0bd075 --- /dev/null +++ b/lib/v2/ustb/yzxc/tzgg.js @@ -0,0 +1,49 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +const host = 'https://yzxc.ustb.edu.cn'; +const url = `${host}/tzgg/index.htm`; + +module.exports = async (ctx) => { + const response = await got(url); + const $ = cheerio.load(response.data); + const list = $('.page_content .ul-inline .box'); + const items = await Promise.all( + list.map((i, item) => { + const $item = $(item); + const time = $item.find('.time').text(); + const titleDom = $item.find('.title a'); + const titleText = titleDom.text(); + const path = titleDom.last().attr('href'); + let itemUrl = ''; + if (path.startsWith('http')) { + itemUrl = path; + } else if (path.startsWith('..')) { + itemUrl = path.replace(/\.\./g, host); + } else { + itemUrl = host + path; + } + return ctx.cache.tryGet(itemUrl, async () => { + let description = titleText; + const result = await got(itemUrl); + const $ = cheerio.load(result.data); + if ($('.article') && $('.article').html()) { + description = $('.article').html().trim(); + } + return { + title: titleText, + link: itemUrl, + pubDate: parseDate(time), + description, + }; + }); + }) + ); + ctx.state.data = { + title: '北京科技大学研究生招生信息网 - 通知公告', + link: url, + description: '北京科技大学研究生招生信息网 - 通知公告', + item: items, + }; +};