feat: routes for umass ipo events&stories (#5225)

This commit is contained in:
Steven Tang
2020-07-28 16:25:35 +01:00
committed by GitHub
parent 426d869bf0
commit 61917a9b75
8 changed files with 115 additions and 2 deletions
+14
View File
@@ -1934,6 +1934,20 @@
target: '/umass/amherst/csnews',
},
],
'www': [
{
title: 'IPO Events',
docs: 'http://docs.rsshub.app/en/university.html#umass-amherst',
source: '/ipo/iss/events',
target: '/umass/amherst/ipoevents',
},
{
title: 'IPO Featured Stories',
docs: 'http://docs.rsshub.app/en/university.html#umass-amherst',
source: '/ipo/iss/featured-stories',
target: '/umass/amherst/ipostories',
},
],
},
'lofter.com': {
_name: 'Lofter',
+10
View File
@@ -33,3 +33,13 @@ pageClass: routes
### College of Information & Computer Sciences News
<RouteEn author="gammapi" example="/umass/amherst/csnews" path="/umass/amherst/csnews" radar="1"/>
### International Programs Office
#### Events
<Route author="gammapi" example="/umass/amherst/ipostories" path="/umass/amherst/ipostories" radar="1"/>
#### Featured Stories
<Route author="gammapi" example="/umass/amherst/ipoevents" path="/umass/amherst/ipoevents" radar="1"/>
+11
View File
@@ -847,6 +847,17 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
<Route author="gammapi" example="/umass/amherst/csnews" path="/umass/amherst/csnews" radar="1"/>
### 国际项目办公室
#### 活动
<Route author="gammapi" example="/umass/amherst/ipostories" path="/umass/amherst/ipostories" radar="1"/>
#### 新闻
<Route author="gammapi" example="/umass/amherst/ipoevents" path="/umass/amherst/ipoevents" radar="1"/>
## 南昌航空大学
### 教务处公告与新闻
+2
View File
@@ -2741,6 +2741,8 @@ router.get('/rf/article', require('./routes/rf/article'));
// University of Massachusetts Amherst
router.get('/umass/amherst/ecenews', require('./routes/umass/amherst/ecenews'));
router.get('/umass/amherst/csnews', require('./routes/umass/amherst/csnews'));
router.get('/umass/amherst/ipoevents', require('./routes/umass/amherst/ipoevents'));
router.get('/umass/amherst/ipostories', require('./routes/umass/amherst/ipostories'));
// 飘花电影网
router.get('/piaohua/hot', require('./routes/piaohua/hot'));
+1 -1
View File
@@ -23,7 +23,7 @@ module.exports = async (ctx) => {
itemPicUrl = item.find('.views-field-field-image img').attr('src');
return {
title: item.find('.views-field-title a').first().text(),
description: `<img src="${itemPicUrl}"><br>` + item.find('.views-field-body .field-content').first().text(),
description: `<img src="${itemPicUrl}"><br/>` + item.find('.views-field-body .field-content').first(),
link: item.find('.views-more-link').attr('href'),
};
})
+1 -1
View File
@@ -24,7 +24,7 @@ module.exports = async (ctx) => {
itemPicUrl = item.find('.image-style-thumbnail').attr('src');
return {
title: item.find('.views-field-title a').first().text(),
description: `<img src="${itemPicUrl}"><br>` + item.find('div.field-content').last().text(),
description: `<img src="${itemPicUrl}"><br/>` + item.find('div.field-content').last(),
link: item.find('.views-field-title a').attr('href'),
};
})
+42
View File
@@ -0,0 +1,42 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: 'https://www.umass.edu/ipo/iss/events',
});
const data = response.data;
const $ = cheerio.load(data);
const list = $('.view-content .ed-abroad-events');
let itemPicUrl;
ctx.state.data = {
title: 'UMAmherst-IpoEvents',
link: 'https://www.umass.edu/ipo/iss/events',
item:
list &&
list
.map((index, item) => {
item = $(item);
eventDateTxt = item.find('.views-field-field-event-date .date-display-single').first();
eventStartDateTxt = item.find('.views-field-field-event-date .date-display-single .date-display-start').first().attr('content');
$.fn.ignore = function(sel) {
return this.clone().find(sel || ">*").remove().end();
};
descTxt = item.find('.views-field-body').first();
return {
title: item.find('.views-field-title a').first().text(),
description: eventDateTxt + '<br/>' + descTxt,
link: item.find('.views-field-title a').attr('href'),
pubDate: new Date(Date.parse(eventStartDateTxt)).toUTCString()
};
})
.get(),
};
};
+34
View File
@@ -0,0 +1,34 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: 'https://www.umass.edu/ipo/iss/featured-stories',
});
const data = response.data;
const $ = cheerio.load(data);
const list = $('.view-content .individualNews');
let itemPicUrl;
ctx.state.data = {
title: 'UMAmherst-IpoStories',
link: 'https://www.umass.edu/ipo/iss/featured-stories',
item:
list &&
list
.map((index, item) => {
item = $(item);
itemPicUrl = item.find('.views-field-field-image img').attr('src');
return {
title: item.find('.views-field-title a').first().text(),
description: `<img src="${itemPicUrl}"><br/>` + item.find('.views-field-field-news-body .field-content').first(),
link: item.find('.views-field-title a').attr('href')
};
})
.get(),
};
};