diff --git a/README.md b/README.md index f15307cbd7..a2c6316dd1 100644 --- a/README.md +++ b/README.md @@ -264,6 +264,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇 - 全国气象预警 - Gitlab - Explore +- 大连工业大学 + - 教务处新闻 diff --git a/docs/README.md b/docs/README.md index ba4c9cc45c..ea9b547b66 100644 --- a/docs/README.md +++ b/docs/README.md @@ -290,6 +290,20 @@ type, 可选, 默认为 `all` | -------- | -------- | ---------- | -------- | -------- | -------- | -------- | -------- | -------- | | 实践创新 | 学科竞赛 | 研究生助教 | 教学改革 | 专业建设 | 课程建设 | 教材建设 | 教学成果 | 学术报告 | +### 大连工业大学 + +#### 教务处新闻 + +举例: [https://rsshub.app/dpu/jiaowu/xwdt](https://rsshub.app/dpu/jiaowu/xwdt) + +路由: `/dpu/jiaowu/:type?` + +参数: type, 可选, 默认为 `xwdt` + +| 新闻动态 | 通知公告 | 教务文件 | +| -------- | -------- | -------- | +| xwdt | tzgg | jwwj | + ## 媒体类 ### 央视新闻 diff --git a/router.js b/router.js index 9ff27efd8a..e931ad8712 100755 --- a/router.js +++ b/router.js @@ -467,4 +467,7 @@ router.get('/weatherAlarm', require('./routes/weatherAlarm')); // Gitlab router.get('/gitlab/explore/:type', require('./routes/gitlab/explore')); +// DPU +router.get('/dpu/jiaowu/:type?', require('./routes/dpu/jiaowu')); + module.exports = router; diff --git a/routes/dpu/jiaowu.js b/routes/dpu/jiaowu.js new file mode 100644 index 0000000000..226765e096 --- /dev/null +++ b/routes/dpu/jiaowu.js @@ -0,0 +1,44 @@ +const axios = require('../../utils/axios'); +const iconv = require('iconv-lite'); +const cheerio = require('cheerio'); +const resolve_url = require('url').resolve; + +const base_url = 'http://jiaowu.dlpu.edu.cn'; + +const map = { + xwdt: '/more/2', + tzgg: '/more/3', + jwwj: '/more/4', +}; + +module.exports = async (ctx) => { + const type = ctx.params.type || 'xwdt'; + const link = `${base_url}${map[type]}`; + + const response = await axios({ + method: 'get', + url: link, + responseType: 'arraybuffer', + headers: { + Referer: base_url, + }, + }); + + const $ = cheerio.load(iconv.decode(response.data, 'gb2312')); + + ctx.state.data = { + link: link, + title: $('#more>h1').text(), + item: $('.more_list>li') + .map((_, elem) => ({ + link: resolve_url(base_url, $('a', elem).attr('href')), + title: $('a', elem).text(), + pubDate: new Date( + $('a>span', elem) + .text() + .replace(/.(\d+)年(\d+)月(\d+)日./, '$1-$2-$3') + ).toUTCString(), + })) + .get(), + }; +};