diff --git a/docs/README.md b/docs/README.md index 8121c49c1..5a4612bce 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1311,6 +1311,24 @@ category 列表: +### 东莞理工学院 + + + +| 教务公告 | 教学信息 | +| -------- | -------- | +| 1 | 2 | + + + + + +| 学工动态 | 通知公告 | 网上公示 | +| -------- | -------- | -------- | +| 1 | 2 | 4 | + + + ## 传统媒体 ### 央视新闻 diff --git a/router.js b/router.js index ca0d4c0f2..61902d545 100644 --- a/router.js +++ b/router.js @@ -586,6 +586,10 @@ router.get('/sdu/epe/:type?', require('./routes/universities/sdu/epe')); // 大连大学 router.get('/dlu/jiaowu/news', require('./routes/universities/dlu/jiaowu/news')); +// 东莞理工学院 +router.get('/dgut/jwc/:type?', require('./routes/universities/dgut/jwc')); +router.get('/dgut/xsc/:type?', require('./routes/universities/dgut/xsc')); + // ifanr router.get('/ifanr/:channel?', require('./routes/ifanr/index')); diff --git a/routes/universities/dgut/jwc.js b/routes/universities/dgut/jwc.js new file mode 100644 index 000000000..afc79ee9d --- /dev/null +++ b/routes/universities/dgut/jwc.js @@ -0,0 +1,62 @@ +const axios = require('../../../utils/axios'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const base_host = 'http://jwc.dgut.edu.cn/'; + const host = base_host + 'dglgjwc/'; + const name = '教务处'; + let type = ctx.params.type; + let info, url_type; + switch (type) { + case '1': + info = '教务公告'; + url_type = 'jwgg'; + break; + case '2': + info = '教学信息'; + url_type = 'jxxx'; + break; + default: + info = '教学信息'; + url_type = 'jxxx'; + } + + const response = await axios({ + method: 'get', + url: host + url_type + '/list.shtml', + headers: { + Referer: base_host, + }, + }); + + const $ = cheerio.load(response.data); + const text = $('div.con-right').find('div.list_div'); + + ctx.state.data = { + title: `东莞理工学院 ${name} ${info}`, + link: host + url_type + '/list.shtml', + description: `东莞理工学院 ${name} ${info}`, + item: + text && + text + .map((index, item) => { + item = $(item); + return { + title: item.find('a').text(), + description: item.find('a').text(), + category: item.find('.column-name').text(), + pubDate: $('td[align="left"]', item) + .slice(5) + .text() + .trim(), + link: + host + + item + .find('a') + .attr('href') + .slice(1), + }; + }) + .get(), + }; +}; diff --git a/routes/universities/dgut/xsc.js b/routes/universities/dgut/xsc.js new file mode 100644 index 000000000..a4a89de5e --- /dev/null +++ b/routes/universities/dgut/xsc.js @@ -0,0 +1,61 @@ +const axios = require('../../../utils/axios'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const host = 'http://xsc.dgut.edu.cn/'; + const name = '学生工作部(学生处)'; + let type = ctx.params.type; + let info, url_type; + switch (type) { + case '1': + info = '学工动态'; + url_type = 'bgfw/xgdt'; + break; + case '2': + info = '通知公告'; + url_type = 'bgfw/tzgg'; + break; + case '4': + info = '网上公示'; + url_type = 'bgfw/wsgs'; + break; + default: + info = '通知公告'; + url_type = 'bgfw/tzgg'; + } + + const response = await axios({ + method: 'get', + url: host + url_type + '/', + headers: { + Referer: host, + }, + }); + + const $ = cheerio.load(response.data); + const text = $('#paging > ul').find('li'); + + ctx.state.data = { + title: `东莞理工学院 ${name} ${info}`, + link: host + url_type + '/index.shtml', + description: `东莞理工学院 ${name} ${info}`, + item: + text && + text + .map((index, item) => { + item = $(item); + return { + title: item.find('a').attr('title'), + description: item.find('a').text(), + pubDate: item.find('.time').text(), + link: + host + + item + .find('a') + .attr('href') + .slice(1), + }; + }) + .get(), + }; +};