fix: shmtu routes (#1721)

This commit is contained in:
Simon Shi 2019-03-11 10:56:52 +08:00 committed by DIYgod
parent 54752afe9b
commit 412d54967f
3 changed files with 68 additions and 75 deletions

View File

@ -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'),
};
}),
};
};

View File

@ -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/..', ''),
};
}),
};
};

View File

@ -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'),
};
}),
};
};