Add 东南大学信息科学与工程学院 -- 学术活动 (#569)

Part of #566
This commit is contained in:
Henry Wang 2018-08-29 11:17:05 +01:00 committed by DIYgod
parent 0c3f41d552
commit b0f824702c
4 changed files with 69 additions and 0 deletions

View File

@ -268,6 +268,9 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
- 文章
- 大连工业大学
- 教务处新闻
- 东南大学
- 信息科学与工程学院
- 学术活动
- 上海科技大学
- 信息科技与技术学院
- 活动

View File

@ -2223,6 +2223,14 @@ type分类
参数: 无
## 东南大学
### 信息科学与工程学院 -- 学术活动 <Author uid="HenryQW"/>
举例: [https://rsshub.app/seu/radio/academic](https://rsshub.app/seu/radio/academic)
路由: `/seu/radio/academic`
## 上海科技大学
### 信息科技与技术学院 -- 活动 <Author uid="HenryQW"/>

View File

@ -473,6 +473,9 @@ router.get('/mygalgame', require('./routes/galgame/mygalgame'));
// DPU
router.get('/dpu/jiaowu/:type?', require('./routes/dpu/jiaowu'));
// 东南大学
router.get('/seu/radio/academic', require('./routes/seu/radio/academic'));
// 上海科技大学
router.get('/shanghaitech/sist/activity', require('./routes/shanghaitech/sist/activity'));

View File

@ -0,0 +1,55 @@
const axios = require('../../../utils/axios');
const cheerio = require('cheerio');
const url = require('url');
const host = 'http://radio.seu.edu.cn/';
module.exports = async (ctx) => {
const link = url.resolve(host, '_s29/15986/list.psp');
const response = await axios.get(link);
const $ = cheerio.load(response.data);
const list = $('.Article_Title a')
.slice(0, 10)
.map((i, e) => $(e).attr('href'))
.get();
const out = await Promise.all(
list.map(async (itemUrl) => {
itemUrl = url.resolve(host, itemUrl);
const cache = await ctx.cache.get(itemUrl);
if (cache) {
return Promise.resolve(JSON.parse(cache));
}
const response = await axios.get(itemUrl);
const $ = cheerio.load(response.data);
const single = {
title: $('.arti_title').text(),
link: itemUrl,
author: $('.arti_publisher')
.text()
.replace('发布者:', ''),
description: $('.wp_articlecontent')
.html()
.replace(/src="\//g, `src="${url.resolve(host, '.')}`)
.trim(),
pubDate: new Date(
$('.arti_update')
.text()
.replace('发布时间:', '')
),
};
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
return Promise.resolve(single);
})
);
ctx.state.data = {
title: '东南大学信息科学与工程学院 -- 学术活动',
link,
item: out,
};
};