From d3a9b3aeb98a50356eb18105e57df9e0a7dd886c Mon Sep 17 00:00:00 2001 From: Derek Date: Sat, 27 Nov 2021 16:56:49 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20update=20to=20v2=20=E5=93=88?= =?UTF-8?q?=E5=B0=94=E6=BB=A8=E5=B7=A5=E7=A8=8B=E5=A4=A7=E5=AD=A6=E8=B7=AF?= =?UTF-8?q?=E7=94=B1=E2=80=94=E2=80=94=E7=A0=94=E7=A9=B6=E7=94=9F=E9=99=A2?= =?UTF-8?q?=E3=80=81=E5=B0=B1=E4=B8=9A=E6=9C=8D=E5=8A=A1=E3=80=81=E5=B7=A5?= =?UTF-8?q?=E5=AD=A6=E6=96=B0=E9=97=BB=E3=80=81=E6=B0=B4=E5=A3=B0=E5=B7=A5?= =?UTF-8?q?=E7=A8=8B=20(#8459)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/radar-rules.js | 21 ---- docs/university.md | 46 +++++---- lib/router.js | 9 -- lib/routes/universities/heu/job.js | 80 ---------------- lib/routes/universities/heu/news.js | 80 ---------------- lib/routes/universities/heu/uae.js | 84 ---------------- lib/routes/universities/heu/ugs/news.js | 122 ------------------------ lib/routes/universities/heu/yjsy.js | 92 ------------------ lib/v2/heu/gx/card.js | 47 +++++++++ lib/v2/heu/gx/list.js | 73 ++++++++++++++ lib/v2/heu/job/bigemploy.js | 42 ++++++++ lib/v2/heu/job/calendar.js | 54 +++++++++++ lib/v2/heu/job/list.js | 70 ++++++++++++++ lib/v2/heu/maintainer.js | 8 ++ lib/v2/heu/radar.js | 73 ++++++++++++++ lib/v2/heu/router.js | 9 ++ lib/v2/heu/uae/list.js | 62 ++++++++++++ lib/v2/heu/yjsy/list.js | 65 +++++++++++++ 18 files changed, 532 insertions(+), 505 deletions(-) delete mode 100644 lib/routes/universities/heu/job.js delete mode 100644 lib/routes/universities/heu/news.js delete mode 100644 lib/routes/universities/heu/uae.js delete mode 100644 lib/routes/universities/heu/ugs/news.js delete mode 100644 lib/routes/universities/heu/yjsy.js create mode 100644 lib/v2/heu/gx/card.js create mode 100644 lib/v2/heu/gx/list.js create mode 100644 lib/v2/heu/job/bigemploy.js create mode 100644 lib/v2/heu/job/calendar.js create mode 100644 lib/v2/heu/job/list.js create mode 100644 lib/v2/heu/maintainer.js create mode 100644 lib/v2/heu/radar.js create mode 100644 lib/v2/heu/router.js create mode 100644 lib/v2/heu/uae/list.js create mode 100644 lib/v2/heu/yjsy/list.js diff --git a/assets/radar-rules.js b/assets/radar-rules.js index 19f3e5cf15..da41fbecb9 100644 --- a/assets/radar-rules.js +++ b/assets/radar-rules.js @@ -626,27 +626,6 @@ { title: '支持的快递公司列表', docs: 'https://docs.rsshub.app/other.html#kuai-di-100', source: '/', target: '/kuaidi100/company' }, ], }, - 'hrbeu.edu.cn': { - _name: '哈尔滨工程大学', - yjsy: [ - { title: '研究生院 - 通知公告', docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue', source: '/*', target: '/heu/yjsy/announcement' }, - { title: '研究生院 - 新闻动态', docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue', source: '/*', target: '/heu/yjsy/news' }, - { title: '研究生院 - 国家公派项目', docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue', source: '/*', target: '/heu/yjsy/gjgp' }, - { title: '研究生院 - 国际合作与交流项目', docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue', source: '/*', target: '/heu/yjsy/gjhz' }, - ], - job: [{ title: '就业服务平台 - 通知公告', docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue', source: '/*', target: '/heu/job/tzgg' }], - uae: [ - { title: '水声学院 - 新闻动态', docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue', source: '/*', target: '/heu/shuisheng/xwdt' }, - { title: '研究生院 - 通知公告', docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue', source: '/*', target: '/heu/shuisheng/tzgg' }, - ], - }, - 'gongxue.cn': { - _name: '工学网', - '.': [ - { title: '要闻', docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue', source: '/*', target: '/heu/gongxue/yw' }, - { title: '时讯', docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue', source: '/*', target: '/heu/gongxue/sx' }, - ], - }, 'nsfc.gov.cn': { _name: '国家自然科学基金委员会', www: [ diff --git a/docs/university.md b/docs/university.md index 108fd832d7..de65159745 100644 --- a/docs/university.md +++ b/docs/university.md @@ -845,41 +845,53 @@ category 列表: ### 研究生院 - + -| 通知公告 | 新闻动态 | 国家公派项目 | 国际合作与交流项目 | -| ------------ | -------- | ------------ | ------------------ | -| announcement | news | gjgp | gjhz | +| 通知公告 | 新闻动态 | 学籍注册 | 奖助学金 | 其他 | +| :------: | :------: | :------: | :------: | :--: | +| 2981 | 2980 | 3009 | 3011 | ... | ### 就业服务平台 - + -| 通知公告 | -| -------- | -| tzgg | +| 通知公告 | 热点新闻 | +| :------: | :------: | +| tzgg | rdxw | + + + +#### 大型招聘会 + + + + + +#### 今日招聘会 + + ### 工学新闻 - + -| 要闻 | 时讯 | -| ---- | ---- | -| yw | sx | +| 新闻 | 新闻 - 要闻 | 新闻 - 专题策划 | 其他 | +| :------: | :---------: | :-------------: | :--: | +| /card/xw | /list/xw/yw | /card/xw/ztch | ... | -### 水声工程学院通知 +### 水声工程学院 - + -| 新闻动态 | 通知公告 | -| -------- | -------- | -| xwdt | tzgg | +| 新闻动态 | 通知公告 | 其他 | +| :------: | :------: | :--: | +| 3751 | 3752 | ... | diff --git a/lib/router.js b/lib/router.js index af924397c9..3d73961688 100644 --- a/lib/router.js +++ b/lib/router.js @@ -710,15 +710,6 @@ router.get('/njupt/jwc/:type?', lazyloadRouteHandler('./routes/universities/njup // 南昌航空大学 router.get('/nchu/jwc/:type?', lazyloadRouteHandler('./routes/universities/nchu/jwc')); -// 哈尔滨工程大学 -router.get('/heu/ugs/news/:author?/:category?', lazyloadRouteHandler('./routes/universities/heu/ugs/news')); -router.get('/heu/yjsy/:type?', lazyloadRouteHandler('./routes/universities/heu/yjsy')); -router.get('/heu/gongxue/:type?', lazyloadRouteHandler('./routes/universities/heu/news')); -router.get('/heu/news/:type?', lazyloadRouteHandler('./routes/universities/heu/news')); -router.get('/heu/shuisheng/:type?', lazyloadRouteHandler('./routes/universities/heu/uae')); -router.get('/heu/uae/:type?', lazyloadRouteHandler('./routes/universities/heu/uae')); -router.get('/heu/job/:type?', lazyloadRouteHandler('./routes/universities/heu/job')); - // 重庆大学 router.get('/cqu/jwc/:path*', lazyloadRouteHandler('./routes/universities/cqu/jwc/announcement')); router.get('/cqu/news/jzyg', lazyloadRouteHandler('./routes/universities/cqu/news/jzyg')); diff --git a/lib/routes/universities/heu/job.js b/lib/routes/universities/heu/job.js deleted file mode 100644 index 88bd492f28..0000000000 --- a/lib/routes/universities/heu/job.js +++ /dev/null @@ -1,80 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); -const url = require('url'); - -const baseUrl = 'http://job.hrbeu.edu.cn'; - -const typeMap = { - tzgg: { - name: '通知公告', - url: '/HrbeuJY/Web/Home/NewsList?43kuJdqqW6kyCmomBv0smMlyGfDy8QefMwSyc-jK8Ww=.shtml', - }, -}; - -module.exports = async (ctx) => { - const type = ctx.params.type || 'tzgg'; - const link = baseUrl + typeMap[type].url; - const response = await got({ - method: 'get', - url: link, - headers: { - Referer: baseUrl, - }, - }); - const $ = cheerio.load(response.data); - - const urlList = $('.wp_article_list .list_item') - .slice(0, 10) - .map((i, e) => $('a', e).attr('href')) - .get(); - - const titleList = $('.wp_article_list .list_item') - .slice(0, 10) - .map((i, e) => $('a', e).attr('title')) - .get(); - - const dateList = $('.wp_article_list .list_item') - .slice(0, 10) - .map((i, e) => $('.Article_PublishDate', e).text()) - .get(); - - const out = await Promise.all( - urlList.map(async (itemUrl, index) => { - itemUrl = url.resolve(baseUrl, itemUrl); - if (itemUrl.indexOf('.shtml') !== -1) { - const cache = await ctx.cache.get(itemUrl); - if (cache) { - return Promise.resolve(JSON.parse(cache)); - } - const response = await got.get(itemUrl); - const $ = cheerio.load(response.data); - const single = { - title: titleList[index], - link: itemUrl, - description: $('.article') - .html() - .replace(/src="\//g, `src="${url.resolve(baseUrl, '.')}`) - .replace(/href="\//g, `href="${url.resolve(baseUrl, '.')}`) - .trim(), - pubDate: dateList[index], - }; - ctx.cache.set(itemUrl, JSON.stringify(single)); - return Promise.resolve(single); - } else { - const single = { - title: titleList[index], - link: itemUrl, - description: '此链接为文件,请点击下载', - pubDate: dateList[index], - }; - return Promise.resolve(single); - } - }) - ); - - ctx.state.data = { - title: 'HEU就业服务平台-' + typeMap[type].name, - link, - item: out, - }; -}; diff --git a/lib/routes/universities/heu/news.js b/lib/routes/universities/heu/news.js deleted file mode 100644 index f7dfe73fce..0000000000 --- a/lib/routes/universities/heu/news.js +++ /dev/null @@ -1,80 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); -const url = require('url'); - -const baseUrl = 'http://news.hrbeu.edu.cn'; - -const typeMap = { - yw: { - name: '要闻', - url: '/xw/yw.htm', - }, - sx: { - name: '时讯', - url: '/xw/sx.htm', - }, -}; - -module.exports = async (ctx) => { - const type = ctx.params.type || 'yw'; - const link = baseUrl + typeMap[type].url; - const response = await got({ - method: 'get', - url: link, - headers: { - Referer: baseUrl, - }, - }); - const $ = cheerio.load(response.data); - - const urlList = $('.list-left-ul .txt-elise') - .slice(0, 10) - .map((i, e) => $('a', e).attr('href')) - .get(); - - const titleList = $('.list-left-ul .txt-elise') - .slice(0, 10) - .map((i, e) => $('a', e).attr('title')) - .get(); - - const dateList = $('.list-left-ul .txt-elise') - .slice(0, 10) - .map((i, e) => $('span', e).text()) - .get(); - - const out = await Promise.all( - urlList.map(async (itemUrl, index) => { - itemUrl = url.resolve(baseUrl, itemUrl); - if (itemUrl.indexOf('.htm') !== -1) { - const cache = await ctx.cache.get(itemUrl); - if (cache) { - return Promise.resolve(JSON.parse(cache)); - } - const response = await got.get(itemUrl); - const $ = cheerio.load(response.data); - const single = { - title: titleList[index], - link: itemUrl, - description: $('.v_news_content').html(), - pubDate: dateList[index], - }; - ctx.cache.set(itemUrl, JSON.stringify(single)); - return Promise.resolve(single); - } else { - const single = { - title: titleList[index], - link: itemUrl, - description: '此链接为跳转,点击标题查看', - pubDate: dateList[index], - }; - return Promise.resolve(single); - } - }) - ); - - ctx.state.data = { - title: '工学新闻-' + typeMap[type].name, - link, - item: out, - }; -}; diff --git a/lib/routes/universities/heu/uae.js b/lib/routes/universities/heu/uae.js deleted file mode 100644 index ebafe125ad..0000000000 --- a/lib/routes/universities/heu/uae.js +++ /dev/null @@ -1,84 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); -const url = require('url'); - -const baseUrl = 'http://uae.hrbeu.edu.cn'; - -const typeMap = { - xwdt: { - name: '新闻动态', - url: '/3751/list.htm', - }, - tzgg: { - name: '通知公告', - url: '/3752/list.htm', - }, -}; - -module.exports = async (ctx) => { - const type = ctx.params.type || 'xwdt'; - const link = baseUrl + typeMap[type].url; - const response = await got({ - method: 'get', - url: link, - headers: { - Referer: baseUrl, - }, - }); - const $ = cheerio.load(response.data); - - const urlList = $('.column-news-item') - .slice(0, 10) - .map((i, e) => $(e).attr('href')) - .get(); - - const titleList = $('.column-news-item') - .slice(0, 10) - .map((i, e) => $('.column-news-title', e).text()) - .get(); - - const dateList = $('.column-news-item') - .slice(0, 10) - .map((i, e) => $('.column-news-date', e).text()) - .get(); - - const out = await Promise.all( - urlList.map(async (itemUrl, index) => { - itemUrl = url.resolve(baseUrl, itemUrl); - if (itemUrl.indexOf('.htm') !== -1) { - const cache = await ctx.cache.get(itemUrl); - if (cache) { - return Promise.resolve(JSON.parse(cache)); - } - const response = await got.get(itemUrl); - const $ = cheerio.load(response.data); - const single = { - title: titleList[index], - link: itemUrl, - description: $('.wp_articlecontent') - .html() - .replace(/src="\//g, `src="${url.resolve(baseUrl, '.')}`) - .replace(/href="\//g, `href="${url.resolve(baseUrl, '.')}`) - .trim(), - pubDate: dateList[index], - }; - ctx.cache.set(itemUrl, JSON.stringify(single)); - return Promise.resolve(single); - } else { - const single = { - title: titleList[index], - link: itemUrl, - description: '此链接为文件,请点击下载', - pubDate: dateList[index], - }; - return Promise.resolve(single); - } - }) - ); - - ctx.state.data = { - title: '水声工程学院-' + typeMap[type].name, - link, - item: out, - }; -}; diff --git a/lib/routes/universities/heu/ugs/news.js b/lib/routes/universities/heu/ugs/news.js deleted file mode 100644 index 776a7e8706..0000000000 --- a/lib/routes/universities/heu/ugs/news.js +++ /dev/null @@ -1,122 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); -const url = require('url'); - -const baseUrl = 'http://ugs.hrbeu.edu.cn'; - -const authorMap = { - gztz: { - all: '/2821', - }, - jwc: { - all: '/jwc', - jxap: '/2847', - ksgl: '/2895', - xjgl: '/2902', - wytk: '/2897', - cjgl: '/2901', - }, - sjjxyjlc: { - all: '/3206', - syjx: '/2847', - sysjs: '/sysjs', - xwsx: '/2909', - xwlw: '/2910', - kcsj: '/2911', - cxcy: '/2913', - xjjl: '/xjjl', - }, - jypgc: { - all: '/3207', - jxyjyjxcg: '/2916', - zljk: '/2917', - }, - zyjsc: { - all: '/3208', - zyyjcjs: '/2914', - cgsyb: '/2925', - jxmsyyxzjjs: '/2918', - ktjs: '/2919', - syjx: '/2920', - }, - gjdxswhszjd: { - all: '/3209', - }, - jsjxfzzx: { - all: '/3210', - jspx: '/2915', - }, - zhbgs: { - all: '/3211', - lxkc: '/lxkc', - }, -}; - -module.exports = async (ctx) => { - const author = ctx.params.author || 'gztz'; - const category = ctx.params.category || 'all'; - const link = baseUrl + authorMap[author][category] + '/list.htm'; - const response = await got({ - method: 'get', - url: link, - headers: { - Referer: baseUrl, - }, - }); - const $ = cheerio.load(response.data); - - const urlList = $('.wp_article_list_table .border9') - .slice(0, 10) - .map((i, e) => $('a', e).attr('href')) - .get(); - - const titleList = $('.wp_article_list_table .border9') - .slice(0, 10) - .map((i, e) => $('a', e).text()) - .get(); - - const dateList = $('.wp_article_list_table .border9') - .slice(0, 10) - .map((i, e) => $('.date', e).text()) - .get(); - - const out = await Promise.all( - urlList.map(async (itemUrl, index) => { - itemUrl = url.resolve(baseUrl, itemUrl); - if (itemUrl.indexOf('.htm') !== -1) { - const cache = await ctx.cache.get(itemUrl); - if (cache) { - return Promise.resolve(JSON.parse(cache)); - } - const response = await got.get(itemUrl); - const $ = cheerio.load(response.data); - const single = { - title: titleList[index], - link: itemUrl, - description: $('.wp_articlecontent') - .html() - .replace(/src="\//g, `src="${url.resolve(baseUrl, '.')}`) - .replace(/href="\//g, `href="${url.resolve(baseUrl, '.')}`) - .trim(), - pubDate: dateList[index], - }; - ctx.cache.set(itemUrl, JSON.stringify(single)); - return Promise.resolve(single); - } else { - const single = { - title: titleList[index], - link: itemUrl, - description: '此链接为文件,请点击下载', - pubDate: dateList[index], - }; - return Promise.resolve(single); - } - }) - ); - - ctx.state.data = { - title: '哈尔滨工程大学本科生院工作通知', - link, - item: out, - }; -}; diff --git a/lib/routes/universities/heu/yjsy.js b/lib/routes/universities/heu/yjsy.js deleted file mode 100644 index 4177bf80f1..0000000000 --- a/lib/routes/universities/heu/yjsy.js +++ /dev/null @@ -1,92 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); -const url = require('url'); - -const baseUrl = 'http://yjsy.hrbeu.edu.cn'; - -const typeMap = { - announcement: { - name: '通知公告', - url: '/2981/list.htm', - }, - news: { - name: '新闻动态', - url: '/2980/list.htm', - }, - gjgp: { - name: '国家公派项目', - url: '/3015/list.htm', - }, - gjhz: { - name: '国际合作与交流项目', - url: '/3016/list.htm', - }, -}; - -module.exports = async (ctx) => { - const type = ctx.params.type || 'announcement'; - const link = baseUrl + typeMap[type].url; - const response = await got({ - method: 'get', - url: link, - headers: { - Referer: baseUrl, - }, - }); - const $ = cheerio.load(response.data); - - const urlList = $('.wp_article_list .list_item') - .slice(0, 10) - .map((i, e) => $('a', e).attr('href')) - .get(); - - const titleList = $('.wp_article_list .list_item') - .slice(0, 10) - .map((i, e) => $('a', e).text()) - .get(); - - const dateList = $('.wp_article_list .list_item') - .slice(0, 10) - .map((i, e) => $('.Article_PublishDate', e).text()) - .get(); - - const out = await Promise.all( - urlList.map(async (itemUrl, index) => { - itemUrl = url.resolve(baseUrl, itemUrl); - if (itemUrl.indexOf('.htm') !== -1) { - const cache = await ctx.cache.get(itemUrl); - if (cache) { - return Promise.resolve(JSON.parse(cache)); - } - const response = await got.get(itemUrl); - const $ = cheerio.load(response.data); - const single = { - title: titleList[index], - link: itemUrl, - description: $('.wp_articlecontent') - .html() - .replace(/src="\//g, `src="${url.resolve(baseUrl, '.')}`) - .replace(/href="\//g, `href="${url.resolve(baseUrl, '.')}`) - .trim(), - pubDate: dateList[index], - }; - ctx.cache.set(itemUrl, JSON.stringify(single)); - return Promise.resolve(single); - } else { - const single = { - title: titleList[index], - link: itemUrl, - description: '此链接为文件,请点击下载', - pubDate: dateList[index], - }; - return Promise.resolve(single); - } - }) - ); - - ctx.state.data = { - title: '研究生院-' + typeMap[type].name, - link, - item: out, - }; -}; diff --git a/lib/v2/heu/gx/card.js b/lib/v2/heu/gx/card.js new file mode 100644 index 0000000000..1e765076bb --- /dev/null +++ b/lib/v2/heu/gx/card.js @@ -0,0 +1,47 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +const rootUrl = 'http://news.hrbeu.edu.cn'; + +module.exports = async (ctx) => { + const date = new Date(); + const hour = date.getHours(); + const minute = date.getMinutes(); + const column = ctx.params.column; + const id = ctx.params.id || ''; + let toUrl; + if (id !== '') { + toUrl = rootUrl.concat('/', column, '/', id, '.htm'); + } else { + toUrl = rootUrl.concat('/', column, '.htm'); + } + + const response = await got({ + method: 'get', + url: toUrl, + headers: { + Referer: rootUrl, + }, + }); + + const $ = cheerio.load(response.data); + + const bigTitle = $('div.list-left-tt') + .text() + .replace(/[ ]|[\r\n]/g, ''); + + const card = $('li.clearfix') + .map((_, item) => ({ + title: $(item).find('div.list-right-tt').text(), + pubDate: $(item).find('span').text() + ' ' + hour + ':' + minute, + link: $(item).find('a').attr('href'), + description: $(item).find('div.list-right-p').text(), + })) + .get(); + + ctx.state.data = { + title: '工学-' + bigTitle, + link: toUrl, + item: card, + }; +}; diff --git a/lib/v2/heu/gx/list.js b/lib/v2/heu/gx/list.js new file mode 100644 index 0000000000..c4c9c001df --- /dev/null +++ b/lib/v2/heu/gx/list.js @@ -0,0 +1,73 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +const rootUrl = 'http://news.hrbeu.edu.cn'; + +module.exports = async (ctx) => { + const date = new Date(); + const hour = date.getHours(); + const minute = date.getMinutes(); + const column = ctx.params.column; + const id = ctx.params.id || ''; + let toUrl; + if (id !== '') { + toUrl = rootUrl.concat('/', column, '/', id, '.htm'); + } else { + toUrl = rootUrl.concat('/', column, '.htm'); + } + + const response = await got({ + method: 'get', + url: toUrl, + headers: { + Referer: rootUrl, + }, + }); + + const $ = cheerio.load(response.data); + + const bigTitle = $('div.list-left-tt') + .text() + .replace(/[ ]|[\r\n]/g, ''); + + const list = $('li.txt-elise') + .map((_, item) => { + let link = $(item).find('a').attr('href'); + if (link.indexOf('info') !== -1 && id !== '') { + link = rootUrl.concat(link.substring(2)); + } + if (link.indexOf('info') !== -1 && id === '') { + link = rootUrl.concat('/', link); + } + return { + title: $(item).find('a').attr('title'), + pubDate: $(item).find('span').text() + ' ' + hour + ':' + minute, + link, + }; + }) + .get(); + + await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + if (item.link.indexOf('info') !== -1) { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + const content = cheerio.load(detailResponse.data); + item.description = content('div.v_news_content').html(); + } else { + item.description = item.title + '

' + '本文需跳转,请点击标题后阅读'; + } + return item; + }) + ) + ); + + ctx.state.data = { + title: '工学-' + bigTitle, + link: toUrl, + item: list, + }; +}; diff --git a/lib/v2/heu/job/bigemploy.js b/lib/v2/heu/job/bigemploy.js new file mode 100644 index 0000000000..2ccda1d12c --- /dev/null +++ b/lib/v2/heu/job/bigemploy.js @@ -0,0 +1,42 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const date = new Date(); + const hour = date.getHours(); + const minute = date.getMinutes(); + + const response = await got({ + method: 'get', + url: 'http://job.hrbeu.edu.cn/HrbeuJY/web', + }); + + const $ = cheerio.load(response.data); + + const list = $('div.articlecontent') + .map((_, item) => { + const link = $(item).find('a.bigTitle').attr('href'); + return { + title: $(item).find('a.bigTitle').text(), + pubDate: + $(item) + .text() + .replace(/[ ]|[\r\n]/g, '') + .substr(-10) + + ' ' + + hour + + ':' + + minute, + description: $(item).find('a.bigTitle').text() + '

' + '点击标题,登录查看招聘详情', + link, + }; + }) + .get(); + + ctx.state.data = { + title: '大型招聘会', + link: 'http://job.hrbeu.edu.cn/HrbeuJY/web', + item: list, + allowEmpty: true, + }; +}; diff --git a/lib/v2/heu/job/calendar.js b/lib/v2/heu/job/calendar.js new file mode 100644 index 0000000000..3da895ed4e --- /dev/null +++ b/lib/v2/heu/job/calendar.js @@ -0,0 +1,54 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +const rootUrl = 'http://job.hrbeu.edu.cn'; + +module.exports = async (ctx) => { + const date = new Date(); + const year = date.getFullYear(); + const month = date.getMonth() + 1; + let strmMonth; + month < 10 ? (strmMonth = '0' + month) : (strmMonth = month); + const day = date.getDate(); + + const response = await got({ + method: 'post', + url: 'http://job.hrbeu.edu.cn/HrbeuJY/Web/Employ/QueryCalendar', + json: { + yearMonth: year + '-' + strmMonth, + }, + }).json(); + + let link = ''; + for (let i = 0, l = response.length; i < l; i++) { + // if (response[i].day === Number('10')) { + if (response[i].day === Number(day)) { + link = response[i].Items[0].link; + } + } + + const todayResponse = await got({ + method: 'get', + url: rootUrl.concat(link), + }); + + const $ = cheerio.load(todayResponse.data); + + const list = $('li.clearfix') + .map((_, item) => { + const link = $(item).find('span.news_tit.news_tit_s').find('a').attr('href'); + return { + title: $(item).find('span.news_tit.news_tit_s').find('a').attr('title'), + description: $(item).find('span.news_tit.news_tit_s').find('a').attr('title') + '

' + '点击标题,登录查看招聘详情', + link, + }; + }) + .get(); + + ctx.state.data = { + title: '今日招聘会', + link: 'http://job.hrbeu.edu.cn/HrbeuJY/web', + item: list, + allowEmpty: true, + }; +}; diff --git a/lib/v2/heu/job/list.js b/lib/v2/heu/job/list.js new file mode 100644 index 0000000000..71526c2a56 --- /dev/null +++ b/lib/v2/heu/job/list.js @@ -0,0 +1,70 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +const rootUrl = 'http://job.hrbeu.edu.cn'; + +const idMap = { + tzgg: { + name: '通知公告', + url: 'http://job.hrbeu.edu.cn/HrbeuJY/Web/Home/NewsList?43kuJdqqW6kyCmomBv0smMlyGfDy8QefMwSyc-jK8Ww=.shtml', + }, + rdxw: { + name: '热点新闻', + url: 'http://job.hrbeu.edu.cn/HrbeuJY/Web/Home/NewsList?43kuJdqqW6kyCmomBv0smLeM5XMyxaJMXP0thrbMBWI=.shtml', + }, +}; + +module.exports = async (ctx) => { + const date = new Date(); + const hour = date.getHours(); + const minute = date.getMinutes(); + const id = ctx.params.id; + + const response = await got({ + method: 'get', + url: idMap[id].url, + headers: { + Referer: rootUrl, + }, + }); + + const $ = cheerio.load(response.data); + + const list = $('li.list_item.i1') + .map((_, item) => { + let link = $(item).find('a').attr('href'); + if (link.indexOf('.shtml') !== -1) { + link = rootUrl.concat(link); + } + return { + title: $(item).find('a').attr('title'), + pubDate: $(item).find('.Article_PublishDate').text() + ' ' + hour + ':' + minute, + link, + }; + }) + .get(); + + await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + if (item.link.indexOf('.shtml') !== -1) { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + const content = cheerio.load(detailResponse.data); + item.description = content('.article').html(); + } else { + item.description = item.title + '

' + '本文需跳转,请点击标题后阅读'; + } + return item; + }) + ) + ); + + ctx.state.data = { + title: '就业服务平台-' + idMap[id].name, + link: idMap[id].url, + item: list, + }; +}; diff --git a/lib/v2/heu/maintainer.js b/lib/v2/heu/maintainer.js new file mode 100644 index 0000000000..643907332e --- /dev/null +++ b/lib/v2/heu/maintainer.js @@ -0,0 +1,8 @@ +module.exports = { + '/yjsy/list/:id': ['Derekmini'], + '/job/bigemploy': ['Derekmini'], + '/job/calendar': ['Derekmini'], + '/job/list/:id': ['Derekmini'], + '/gx/:type/:colume/:id?': ['Derekmini'], + '/uae/list/:id': ['Derekmini'], +}; diff --git a/lib/v2/heu/radar.js b/lib/v2/heu/radar.js new file mode 100644 index 0000000000..1edde32363 --- /dev/null +++ b/lib/v2/heu/radar.js @@ -0,0 +1,73 @@ +module.exports = { + 'hrbeu.edu.cn': { + _name: '哈尔滨工程大学', + yjsy: [ + { + title: '研究生院', + docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue', + source: '/:id/list.htm', + target: '/heu/yjsy/list/:id', + }, + ], + job: [ + { + title: '大型招聘会', + docs: 'https://docs.rsshub.app/journal.html#ha-er-bin-gong-cheng-da-xue', + source: '/*', + target: '/heu/job/bigemploy', + }, + { + title: '今日招聘会', + docs: 'https://docs.rsshub.app/journal.html#ha-er-bin-gong-cheng-da-xue', + source: '/*', + target: '/heu/job/calendar', + }, + { + title: '就业服务平台-通知公告', + docs: 'https://docs.rsshub.app/journal.html#ha-er-bin-gong-cheng-da-xue', + source: '/*', + target: '/heu/job/list/tzgg', + }, + { + title: '就业服务平台-热点新闻', + docs: 'https://docs.rsshub.app/journal.html#ha-er-bin-gong-cheng-da-xue', + source: '/*', + target: '/heu/job/list/rdxw', + }, + ], + news: [ + { + title: '工学', + docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue', + source: '/:column', + target: (params) => `/heu/gx/list/${params.column.replace('.htm', '')}`, + }, + { + title: '工学', + docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue', + source: '/:column/:id', + target: (params) => `/heu/gx/list/${params.column}/${params.id.replace('.htm', '')}`, + }, + { + title: '工学-card', + docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue', + source: '/:column', + target: (params) => `/heu/gx/card/${params.column.replace('.htm', '')}`, + }, + { + title: '工学-card', + docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue', + source: '/:column/:id', + target: (params) => `/heu/gx/card/${params.column}/${params.id.replace('.htm', '')}`, + }, + ], + uae: [ + { + title: '水声学院', + docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue', + source: '/:id/list.htm', + target: '/heu/uae/list/:id', + }, + ], + }, +}; diff --git a/lib/v2/heu/router.js b/lib/v2/heu/router.js new file mode 100644 index 0000000000..84fe34642b --- /dev/null +++ b/lib/v2/heu/router.js @@ -0,0 +1,9 @@ +module.exports = function (router) { + router.get('/yjsy/list/:id', require('./yjsy/list')); + router.get('/job/bigemploy', require('./job/bigemploy')); + router.get('/job/calendar', require('./job/calendar')); + router.get('/job/list/:id', require('./job/list')); + router.get('/gx/list/:column/:id?', require('./gx/list')); + router.get('/gx/card/:column/:id?', require('./gx/card')); + router.get('/uae/list/:id', require('./uae/list')); +}; diff --git a/lib/v2/heu/uae/list.js b/lib/v2/heu/uae/list.js new file mode 100644 index 0000000000..098bc1a1c9 --- /dev/null +++ b/lib/v2/heu/uae/list.js @@ -0,0 +1,62 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +const rootUrl = 'http://uae.hrbeu.edu.cn'; + +module.exports = async (ctx) => { + const date = new Date(); + const hour = date.getHours(); + const minute = date.getMinutes(); + const id = ctx.params.id; + + const response = await got({ + method: 'get', + url: rootUrl.concat('/', id, '/list.htm'), + headers: { + Referer: rootUrl, + }, + }); + + const $ = cheerio.load(response.data); + + const bigTitle = $('h2.column-title').text(); + + const list = $('a.column-news-item') + .map((_, item) => { + let link = $(item).attr('href'); + if (link.indexOf('page.htm') !== -1) { + link = rootUrl.concat(link); + } + return { + title: $(item).find('span.column-news-title').text(), + pubDate: $(item).find('span.column-news-date').text() + ' ' + hour + ':' + minute, + link, + }; + }) + .get(); + + await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + if (item.link.indexOf('page.htm') !== -1) { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + const content = cheerio.load(detailResponse.data); + item.description = content('div.wp_articlecontent').html(); + item.title = content('h1.arti-title').text(); + } else { + item.description = item.title + '

' + '本文需跳转,请点击标题后阅读'; + } + return item; + }) + ) + ); + + ctx.state.data = { + title: '水声学院-' + bigTitle, + link: rootUrl.concat('/', id, '/list.htm'), + item: list, + }; +}; diff --git a/lib/v2/heu/yjsy/list.js b/lib/v2/heu/yjsy/list.js new file mode 100644 index 0000000000..28549faba2 --- /dev/null +++ b/lib/v2/heu/yjsy/list.js @@ -0,0 +1,65 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +const rootUrl = 'http://yjsy.hrbeu.edu.cn'; + +module.exports = async (ctx) => { + const date = new Date(); + const hour = date.getHours(); + const minute = date.getMinutes(); + const id = ctx.params.id; + + const response = await got({ + method: 'get', + url: rootUrl.concat('/', id, '/list.htm'), + headers: { + Referer: rootUrl, + }, + }); + + const $ = cheerio.load(response.data); + + const bigTitle = $('div [id=lanmuInnerMiddleBigClass_right]') + .find('div [portletmode=simpleColumnAttri]') + .text() + .replace(/[ ]|[\r\n\t]|[·]/g, '') + .trim(); + + const list = $('li.list_item') + .map((_, item) => { + let link = $(item).find('a').attr('href'); + if (link.indexOf('page.htm') !== -1) { + link = rootUrl.concat(link); + } + return { + title: $(item).find('a').attr('title'), + pubDate: $(item).find('span.Article_PublishDate').text() + ' ' + hour + ':' + minute, + link, + }; + }) + .get(); + + await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + if (item.link.indexOf('page.htm') !== -1) { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + const content = cheerio.load(detailResponse.data); + item.description = content('div.wp_articlecontent').html(); + } else { + item.description = item.title + '

' + '本文需跳转,请点击标题后阅读'; + } + return item; + }) + ) + ); + + ctx.state.data = { + title: '研究生院-' + bigTitle, + link: rootUrl.concat('/', id, '/list.htm'), + item: list, + }; +};