diff --git a/lib/routes/universities/shmtu/events.js b/lib/routes/universities/shmtu/events.js index ea6d1de4f..509a528e2 100644 --- a/lib/routes/universities/shmtu/events.js +++ b/lib/routes/universities/shmtu/events.js @@ -2,7 +2,7 @@ const axios = require('../../../utils/axios'); const cheerio = require('cheerio'); module.exports = async (ctx) => { - const host = 'https://www.shmtu.edu.cn'; + const host = 'http://www.shmtu.edu.cn'; const response = await axios({ method: 'get', @@ -21,31 +21,31 @@ module.exports = async (ctx) => { description: '上海海事大学 学术讲座', item: text && - text - .map((index, item) => { - item = $(item); - return { - title: item - .find('.title') + text.map((item) => { + item = $(item); + return { + title: item + .find('.title') + .text() + .trim(), + description: item + .find('.title') + .text() + .trim(), + author: + '发布部门 - ' + + item + .find('.department') .text() .trim(), - description: item - .find('.title') - .text() - .trim(), - author: - '发布部门 - ' + - item - .find('.department') - .text() - .trim(), - pubDate: item + pubDate: new Date( + item .find('span') .find('span') - .attr('content'), - link: host + item.find('a').attr('href'), - }; - }) - .get(), + .attr('content') + ).toUTCString(), + link: host + item.find('a').attr('href'), + }; + }), }; }; diff --git a/lib/routes/universities/shmtu/jwc.js b/lib/routes/universities/shmtu/jwc.js index a85d4a3d3..cbdfa27b8 100644 --- a/lib/routes/universities/shmtu/jwc.js +++ b/lib/routes/universities/shmtu/jwc.js @@ -3,13 +3,8 @@ const cheerio = require('cheerio'); module.exports = async (ctx) => { const host = 'http://jwc.shmtu.edu.cn/Information/'; - let type = ctx.params.type; - let info = '教务新闻'; - if (type === '2') { - info = '教务公告'; - } else { - type = '1'; - } + const type = ctx.params.type; + const info = type === '2' ? '教务公告' : '教务新闻'; const response = await axios({ method: 'get', @@ -28,25 +23,25 @@ module.exports = async (ctx) => { description: `上海海事大学 ${info}`, item: text && - text - .map((index, item) => { - item = $(item); - return { - title: item.find('a').attr('title'), - description: item.find('a').attr('title'), - author: - '信息类别 - ' + - $('.gvItemNormal', item) - .slice(1, 2) - .text() - .trim(), - pubDate: $('.gvItemNormal', item) - .slice(4) + text.map((item) => { + item = $(item); + return { + title: item.find('a').attr('title'), + description: item.find('a').attr('title'), + author: + '信息类别 - ' + + $('.gvItemNormal', item) + .slice(1, 2) .text() .trim(), - link: (host + item.find('a').attr('href')).replace('/Information/..', ''), - }; - }) - .get(), + pubDate: new Date( + $('.gvItemNormal', item) + .slice(4) + .text() + .trim() + ).toUTCString(), + link: (host + item.find('a').attr('href')).replace('/Information/..', ''), + }; + }), }; }; diff --git a/lib/routes/universities/shmtu/notes.js b/lib/routes/universities/shmtu/notes.js index 8ad425d44..ec315fceb 100644 --- a/lib/routes/universities/shmtu/notes.js +++ b/lib/routes/universities/shmtu/notes.js @@ -2,7 +2,7 @@ const axios = require('../../../utils/axios'); const cheerio = require('cheerio'); module.exports = async (ctx) => { - const host = 'https://www.shmtu.edu.cn'; + const host = 'http://www.shmtu.edu.cn'; const response = await axios({ method: 'get', @@ -21,33 +21,31 @@ module.exports = async (ctx) => { description: '上海海事大学 通知公告', item: text && - text - .map((index, item) => { - item = $(item); - return { - title: item - .find('.title') + text.map((item) => { + item = $(item); + return { + title: item + .find('.title') + .text() + .trim(), + description: item + .find('.title') + .text() + .trim(), + author: + '发布部门 - ' + + item + .find('.department') .text() .trim(), - description: item - .find('.title') - .text() - .trim(), - author: - '发布部门 - ' + - item - .find('.department') - .text() - .trim(), - pubDate: new Date( - item - .find('span') - .find('span') - .attr('content') - ).toUTCString(), - link: host + item.find('a').attr('href'), - }; - }) - .get(), + pubDate: new Date( + item + .find('span') + .find('span') + .attr('content') + ).toUTCString(), + link: host + item.find('a').attr('href'), + }; + }), }; };