diff --git a/docs/university.md b/docs/university.md index 0318f11805..6131708a42 100644 --- a/docs/university.md +++ b/docs/university.md @@ -683,6 +683,22 @@ xskb1 对应 +## 东华大学 + +### 教务处通知 + + + +| 学生专栏 | 教师专栏 | +| ------- | ------- | +| student | teacher | + + + +### 最新信息公开 + + + ## 东南大学 ### 信息科学与工程学院学术活动 diff --git a/lib/v2/dhu/jiaowu/news.js b/lib/v2/dhu/jiaowu/news.js new file mode 100644 index 0000000000..ab2d96590e --- /dev/null +++ b/lib/v2/dhu/jiaowu/news.js @@ -0,0 +1,37 @@ +const got = require('@/utils/got'); +const iconv = require('iconv-lite'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); + +const base_url = 'https://jw.dhu.edu.cn'; + +const map = { + student: '/tzggwxszl/list.htm', + teacher: '/tzggwjszl/list.htm', +}; +module.exports = async (ctx) => { + const type = ctx.params.type; + const link = map.hasOwnProperty(type) ? `${base_url}${map[type]}` : `${base_url}/tzggwxszl/list.htm`; + const response = await got({ + method: 'get', + url: link, + responseType: 'buffer', + headers: { + Referer: base_url, + }, + }); + + const $ = cheerio.load(iconv.decode(response.data, 'utf-8')); + ctx.state.data = { + link: base_url, + title: '东华大学教务处-' + $('.col_title').text(), + item: $('.list_item') + .map((_, elem) => ({ + link: new URL($('a', elem).attr('href'), base_url), + title: $('a', elem).attr('title'), + pubDate: timezone(parseDate($('.Article_PublishDate', elem).text()), +8), + })) + .get(), + }; +}; diff --git a/lib/v2/dhu/maintainer.js b/lib/v2/dhu/maintainer.js new file mode 100644 index 0000000000..4993d1b370 --- /dev/null +++ b/lib/v2/dhu/maintainer.js @@ -0,0 +1,4 @@ +module.exports = { + '/jiaowu/news/:type?': ['KiraKiseki'], + '/xxgk/news': ['KiraKiseki'], +}; diff --git a/lib/v2/dhu/radar.js b/lib/v2/dhu/radar.js new file mode 100644 index 0000000000..a99cdd9ccd --- /dev/null +++ b/lib/v2/dhu/radar.js @@ -0,0 +1,17 @@ +module.exports = { + 'dhu.edu.cn': { + _name: '东华大学', + jw: [ + { + title: '教务处通知', + docs: 'https://docs.rsshub.app/university.html#dong-hua-da-xue', + }, + ], + xxgk: [ + { + title: '最新信息公开', + docs: 'https://docs.rsshub.app/university.html#dong-hua-da-xue', + }, + ], + }, +}; diff --git a/lib/v2/dhu/router.js b/lib/v2/dhu/router.js new file mode 100644 index 0000000000..11dfa6b54d --- /dev/null +++ b/lib/v2/dhu/router.js @@ -0,0 +1,4 @@ +module.exports = function (router) { + router.get('/jiaowu/news/:type?', require('./jiaowu/news')); + router.get('/xxgk/news', require('./xxgk/news')); +}; diff --git a/lib/v2/dhu/xxgk/news.js b/lib/v2/dhu/xxgk/news.js new file mode 100644 index 0000000000..a83b85729d --- /dev/null +++ b/lib/v2/dhu/xxgk/news.js @@ -0,0 +1,32 @@ +const got = require('@/utils/got'); +const iconv = require('iconv-lite'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); + +const base_url = 'https://xxgk.dhu.edu.cn/1737/list.htm'; + +module.exports = async (ctx) => { + const link = base_url; + const response = await got({ + method: 'get', + url: link, + responseType: 'buffer', + headers: { + Referer: base_url, + }, + }); + + const $ = cheerio.load(iconv.decode(response.data, 'utf-8')); + ctx.state.data = { + link: base_url, + title: '东华大学信息公开网-最新公开信息', + item: $('.cols') + .map((_, elem) => ({ + link: new URL($('a', elem).attr('href'), base_url), + title: $('a', elem).attr('title'), + pubDate: timezone(parseDate($('.cols_meta', elem).text()), +8), + })) + .get(), + }; +};