rss: Trim shmtu string (#813)

This commit is contained in:
Simon Shi
2018-09-30 15:12:57 +08:00
committed by DIYgod
parent 309507c836
commit 5144e09b6f
3 changed files with 37 additions and 10 deletions
+15 -3
View File
@@ -2,7 +2,7 @@ const axios = require('../../../utils/axios');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const host = 'http://www.shmtu.edu.cn';
const host = 'https://www.shmtu.edu.cn';
const response = await axios({
method: 'get',
@@ -25,8 +25,20 @@ module.exports = async (ctx) => {
.map((index, item) => {
item = $(item);
return {
title: item.find('.title').text(),
description: '发布部门 - ' + item.find('.department').text(),
title: item
.find('.title')
.text()
.trim(),
description: item
.find('.title')
.text()
.trim(),
author:
'发布部门 - ' +
item
.find('.department')
.text()
.trim(),
pubDate: item
.find('span')
.find('span')
+7 -4
View File
@@ -33,15 +33,18 @@ module.exports = async (ctx) => {
item = $(item);
return {
title: item.find('a').attr('title'),
description:
description: item.find('a').attr('title'),
author:
'信息类别 - ' +
$('.gvItemNormal', item)
.slice(1, 2)
.text(),
.text()
.trim(),
pubDate: $('.gvItemNormal', item)
.slice(4)
.text(),
link: host + item.find('a').attr('href'),
.text()
.trim(),
link: (host + item.find('a').attr('href')).replace('/Information/..', ''),
};
})
.get(),
+15 -3
View File
@@ -2,7 +2,7 @@ const axios = require('../../../utils/axios');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const host = 'http://www.shmtu.edu.cn';
const host = 'https://www.shmtu.edu.cn';
const response = await axios({
method: 'get',
@@ -25,8 +25,20 @@ module.exports = async (ctx) => {
.map((index, item) => {
item = $(item);
return {
title: item.find('.title').text(),
description: '发布部门 - ' + item.find('.department').text(),
title: item
.find('.title')
.text()
.trim(),
description: item
.find('.title')
.text()
.trim(),
author:
'发布部门 - ' +
item
.find('.department')
.text()
.trim(),
pubDate: item
.find('span')
.find('span')