From 9d13d768cd713256e2fd85935b4d65c5a8d82dee Mon Sep 17 00:00:00 2001 From: fox2049 <60031998+fox2049@users.noreply.github.com> Date: Wed, 7 Jun 2023 20:16:00 +0800 Subject: [PATCH] feat(router): add link content of dhu/yjs/zs (#12627) * add yjszs info of dhu * change order and add zs make * 4 spaces for indentation, camelCase, del utf-8 decoder, link to string * code proofreading * delete got params * update link code * delete link body in ctx.state.data * Update lib/v2/dhu/maintainer.js * code proofreading * example update * html parse update * add content * delete comments * delete comments * update code from remote * add link content * link update --------- Co-authored-by: Yuexin Sun --- docs/university.md | 22 +++++++++++----------- lib/v2/dhu/yjs/zs.js | 30 ++++++++++++++++++++++-------- 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/docs/university.md b/docs/university.md index 24b76434b..140786b76 100644 --- a/docs/university.md +++ b/docs/university.md @@ -619,7 +619,7 @@ pageClass: routes | 博士研究生 | 硕士研究生 | 同等学力攻读硕士学位 | 港澳台地区招生 | | :--------: | :--------: | :------------------: | :------------: | -| bsyjs | ssyjs | tdxlgdssxw | gatdqzs | +| bsyjs | ssyjs | tdxlgdssxw | gatdqzs | @@ -1013,7 +1013,7 @@ pageClass: routes ### 研究生招生信息 - + | 博士招生 | 硕士招生 | | -------- | -------- | @@ -1229,7 +1229,7 @@ category 列表: | 通知公告 | 新闻动态 | 学籍注册 | 奖助学金 | 其他 | | :------: | :------: | :------: | :------: | :--: | -| 2981 | 2980 | 3009 | 3011 | ... | +| 2981 | 2980 | 3009 | 3011 | ... | @@ -1261,7 +1261,7 @@ category 列表: | 新闻 | 新闻 - 要闻 | 新闻 - 专题策划 | 其他 | | :------: | :---------: | :-------------: | :--: | -| /card/xw | /list/xw/yw | /card/xw/ztch | ... | +| /card/xw | /list/xw/yw | /card/xw/ztch | ... | @@ -1271,7 +1271,7 @@ category 列表: | 新闻动态 | 通知公告 | 其他 | | :------: | :------: | :--: | -| 3751 | 3752 | ... | +| 3751 | 3752 | ... | @@ -2348,7 +2348,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS | 通知公告 | 本科生教务 | 研究生教务 | | :------: | :--------: | :--------: | -| tzgg | bksjw | yjsjw | +| tzgg | bksjw | yjsjw | @@ -2796,7 +2796,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS | 聚焦天大 | 综合新闻 | 校内新闻 | 媒体报道 | 图说天大 | | :------: | :------: | :------: | :------: | :------: | -| focus | general | internal | media | picture | +| focus | general | internal | media | picture | @@ -2806,7 +2806,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS | 学部新闻 | 通知公告 | 北洋智算论坛 | | :------: | :----------: | :----------: | -| news | notification | forum | +| news | notification | forum | @@ -2826,7 +2826,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS | 校级公告 | 统考硕士 | 统考博士 | 在职学位 | | :------: | :------: | :------: | :------: | -| notice | master | doctor | job | +| notice | master | doctor | job | @@ -2874,7 +2874,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS | 温大新闻 | 媒体温大 | 学术温大 | 通知公告 | 招标信息 | 学术公告 | | :------: | :------: | :------: | :------: | :------: | :------: | -| 0 | 1 | 2 | 3 | 4 | 5 | +| 0 | 1 | 2 | 3 | 4 | 5 | @@ -3683,7 +3683,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS | 招聘类型 | 博士后 | 课题项目聘用 | 管理支撑人才 | 教学科研人才 | | :------: | :----: | :----------: | :----------: | :----------: | -| 参数 | bsh | ktxmpy | glzcrc | jxkyrc | +| 参数 | bsh | ktxmpy | glzcrc | jxkyrc | diff --git a/lib/v2/dhu/yjs/zs.js b/lib/v2/dhu/yjs/zs.js index cb747a744..9cf0de5ac 100644 --- a/lib/v2/dhu/yjs/zs.js +++ b/lib/v2/dhu/yjs/zs.js @@ -1,7 +1,6 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); const { parseDate } = require('@/utils/parse-date'); -const timeZone = require('@/utils/timezone'); const baseUrl = 'https://yjszs.dhu.edu.cn'; @@ -15,14 +14,29 @@ module.exports = async (ctx) => { const { data: response } = await got(link); const $ = cheerio.load(response); + const list = $('.list_item') + .toArray() + .map((item) => { + item = $(item); + const a = item.find('a').first(); + return { + title: a.attr('title'), + link: `${baseUrl}${a.attr('href')}`, + pubDate: parseDate(item.find('.Article_PublishDate').text()), + }; + }); - const items = $('.list_item') - .map((_, elem) => ({ - link: new URL($('a', elem).attr('href'), baseUrl).href, - title: $('a', elem).attr('title'), - pubDate: timeZone(parseDate($('.Article_PublishDate', elem).text()), +8), - })) - .get(); + // item content + const items = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + const { data: response } = await got(item.link); + const $ = cheerio.load(response); + item.description = $('.wp_articlecontent').first().html(); + return item; + }) + ) + ); ctx.state.data = { title: '东华大学研究生-' + $('.col_title').text(),