diff --git a/docs/university.md b/docs/university.md index 26c239cdd..fca9af2e8 100644 --- a/docs/university.md +++ b/docs/university.md @@ -2974,7 +2974,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS ### 信息门户公告 - + | 公告类型 | 通知公告 | 教务信息 | 科研动态 | | -------- | -------- | -------- | -------- | @@ -2982,6 +2982,16 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS +### 就业信息 + + + +| 信息类型 | 消息通知 | 通知公告 | 新闻快递 | +| -------- | -------- | -------- | -------- | +| 参数 | xxtz | tzgg | xwkd | + + + ## 西安财经大学 ### 教务处 diff --git a/lib/router.js b/lib/router.js index 83c4826af..95873d3ea 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3719,7 +3719,7 @@ router.get('/thrillist/:tag?', lazyloadRouteHandler('./routes/thrillist/index')) router.get('/dxy/vaccine/:province?/:city?/:location?', lazyloadRouteHandler('./routes/dxy/vaccine')); // Wtu -router.get('/wtu/:type', lazyloadRouteHandler('./routes/universities/wtu')); +// router.get('/wtu/:type', lazyloadRouteHandler('./routes/universities/wtu')); // 中国庭审公开网 router.get('/tingshen', lazyloadRouteHandler('./routes/tingshen/tingshen')); diff --git a/lib/routes/universities/wtu/index.js b/lib/routes/universities/wtu/index.js deleted file mode 100644 index d0eeed0a4..000000000 --- a/lib/routes/universities/wtu/index.js +++ /dev/null @@ -1,34 +0,0 @@ -const got = require('@/utils/got'); - -const apiUrl = 'http://ehall.wtu.edu.cn/wtu/api/queryBulletinListByConditional.do?pageNum=1&pageSize=8&columnId='; -const listUrl = 'http://ehall.wtu.edu.cn/new/list.html?type='; -const psgUrl = 'http://ehall.wtu.edu.cn/new/detail-word.html?'; -const map = new Map([ - [1, { title: '通知公告', type: '2', id: '1994a3b58bef4ee887e1efc19881decd' }], - [2, { title: '教务信息', type: '5', id: '36d47fcd3e774f289adfef1d93138a9d' }], - [3, { title: '科研动态', type: '3', id: '48e8abfb983b4e4486b69feacad1dc1b' }], -]); - -module.exports = async (ctx) => { - const typein = Number.parseInt(ctx.params.type); - const title = map.get(typein).title; - const columnId = map.get(typein).id; - const type = map.get(typein).type; - const res = await got({ - method: 'get', - url: `${apiUrl}${columnId}`, - }); - const res_json = res.data.bulletinList; - - ctx.state.data = { - title: `${title} - 武汉纺织大学信息门户`, - link: `${listUrl}${type}`, - description: `${title} - 武汉纺织大学信息门户`, - item: res_json.map((item) => ({ - title: item.TITLE, - description: item.TITLE, - pubDate: new Date(item.CREATE_TIME).toUTCString(), - link: `${psgUrl}type=${type}?bulletinId=${item.WID}`, - })), - }; -}; diff --git a/lib/v2/wtu/index.js b/lib/v2/wtu/index.js new file mode 100644 index 000000000..c923d8040 --- /dev/null +++ b/lib/v2/wtu/index.js @@ -0,0 +1,37 @@ +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); + +module.exports = async (ctx) => { + const apiUrl = 'https://ehall.wtu.edu.cn/wtu/api/queryBulletinListByConditional.do?pageNum=1&pageSize=20&columnId='; + const listUrl = 'https://ehall.wtu.edu.cn/new/list.html?type='; + const psgUrl = 'https://ehall.wtu.edu.cn/new/detail-word.html?'; + const map = new Map([ + [1, { title: '通知公告', type: '2', id: '1994a3b58bef4ee887e1efc19881decd' }], + [2, { title: '教务信息', type: '6', id: '36d47fcd3e774f289adfef1d93138a9d' }], + [3, { title: '科研动态', type: '7', id: '48e8abfb983b4e4486b69feacad1dc1b' }], + ]); + + const typeInt = parseInt(ctx.params.type); + const value = map.get(typeInt); + const title = value.title; + const columnId = value.id; + const type = value.type; + const res = await got({ + method: 'get', + url: `${apiUrl}${columnId}`, + }); + const resJson = res.data.bulletinList; + + ctx.state.data = { + title: `${title} - 武汉纺织大学信息门户`, + link: `${listUrl}${type}`, + description: `${title} - 武汉纺织大学信息门户`, + item: resJson.map((item) => ({ + title: item.TITLE, + pubDate: timezone(parseDate(item.CREATE_TIME), 8), + link: item.GOTO_URL ?? `${psgUrl}type=${type}?bulletinId=${item.WID}`, + author: item.PUBLISH_USER_DEPT_NAME, + })), + }; +}; diff --git a/lib/v2/wtu/job.js b/lib/v2/wtu/job.js new file mode 100644 index 000000000..90cd9b41c --- /dev/null +++ b/lib/v2/wtu/job.js @@ -0,0 +1,80 @@ +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); +const zlib = require('zlib'); +const cheerio = require('cheerio'); + +const baseUrl = 'https://wtu.91wllm.com/'; + +const typeMap = new Map([ + ['xxtz', { title: '信息通知', url: `${baseUrl}news/index/tag/xxtz` }], + ['tzgg', { title: '通知公告', url: `${baseUrl}news/index/tag/tzgg` }], + ['xwkd', { title: '新闻快递', url: `${baseUrl}news/index/tag/xwkd` }], +]); + +/** + * 解压缩数据 + * @param {String} str + * @returns {String} + */ +function decodeData(str) { + // 匹配正则 + const regex = /Base64.decode\(unzip\("(.+?)"\)\.substr\((\d+)\)\)\.substr\((\d+)\)/; + const match = str.match(regex); + if (!match) { + return ''; + } + // 获取数据 + const compressedContent = match[1]; + const substr1Num = Number.parseInt(match[2]); + const substr2Num = Number.parseInt(match[3]); + // 解压缩 + const unzipContent = zlib.inflateSync(Buffer.from(compressedContent, 'base64')).toString('utf8'); + const content = Buffer.from(unzipContent.substring(substr1Num), 'base64'); + return content.toString('utf8').substring(substr2Num); +} + +module.exports = async (ctx) => { + // 获取参数 type + const type = ctx.params.type; + const mapItem = typeMap.get(type); + const msgTitle = `${mapItem.title} - 武汉纺织大学就业信息`; + const link = mapItem.url; + + // 请求网页 + const resp = await got.get(link); + // 解压缩列表数据 + const listStr = decodeData(resp.data); + // 解析列表数据 + const $ = cheerio.load(listStr); + const list = $('.newsList') + .toArray() + .map((item) => { + item = $(item); + const $date = item.find("li[class='span2 y']").text(); + const $linkLi = item.find('li>a'); + const $url = new URL($linkLi.attr('href'), baseUrl).href; + return { + title: $linkLi.text(), + pubDate: parseDate($date, 'YYYY-MM-DD'), + link: $url, + }; + }); + // 获取全文信息 + const items = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + const { data: response } = await got.get(item.link); + const content = decodeData(response); + item.description = content; + return item; + }) + ) + ); + + ctx.state.data = { + title: msgTitle, + link, + description: msgTitle, + item: items, + }; +}; diff --git a/lib/v2/wtu/maintainer.js b/lib/v2/wtu/maintainer.js new file mode 100644 index 000000000..b79e338c1 --- /dev/null +++ b/lib/v2/wtu/maintainer.js @@ -0,0 +1,4 @@ +module.exports = { + '/:type': ['loyio'], + '/job/:type': ['ticks-tan'], +}; diff --git a/lib/v2/wtu/radar.js b/lib/v2/wtu/radar.js new file mode 100644 index 000000000..2030e8a4c --- /dev/null +++ b/lib/v2/wtu/radar.js @@ -0,0 +1,22 @@ +module.exports = { + '91wllm.com': { + _name: '湖北高校就业网络联盟', + wtu: [ + { + title: '武汉纺织大学就业信息', + docs: 'https://docs.rsshub.app/university.html#wu-han-fang-zhi-da-xue', + source: '/news/index/tag/:type', + target: '/wtu/job/:type', + }, + ], + }, + 'wtu.edu.cn': { + _name: '武汉纺织大学', + wtu: [ + { + title: '信息门户公告', + docs: 'https://docs.rsshub.app/university.html#wu-han-fang-zhi-da-xue', + }, + ], + }, +}; diff --git a/lib/v2/wtu/router.js b/lib/v2/wtu/router.js new file mode 100644 index 000000000..3e2240894 --- /dev/null +++ b/lib/v2/wtu/router.js @@ -0,0 +1,4 @@ +module.exports = (router) => { + router.get('/:type', require('./index')); + router.get('/job/:type', require('./job')); +};