mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-13 00:35:57 +08:00
增加了上海交通大学电院学生办信息通告 (#1243)
This commit is contained in:
@@ -1284,6 +1284,14 @@ GitHub 官方也提供了一些 RSS:
|
||||
|
||||
</route>
|
||||
|
||||
<route name="电子信息与电气工程学院学生工作办公室" author="Polynomia" example="/sjtu/seiee/xsb/news" path="/universities/sjtu/seiee/xsb/:type?" :paramsDesc="['默认列举所有通知公告']">
|
||||
|
||||
| 信息通告 | 奖学金 | 助学金 | 讲座活动 | 党团活动 | 新闻发布 |
|
||||
| -------- | ----------- | ------------ | -------- | -------- | -------- |
|
||||
| 空 | scholarship | financialAid | lecture | activity | news |
|
||||
|
||||
</route>
|
||||
|
||||
### 中国科学院
|
||||
|
||||
<route name="上海微系统与信息技术研究所学术活动" author="HenryQW" example="/cas/sim/academic" path="/universities/cas/sim/academic"/>
|
||||
|
||||
@@ -551,6 +551,7 @@ router.get('/sjtu/seiee/bjwb/major_transfer', require('./routes/universities/sjt
|
||||
router.get('/sjtu/seiee/bjwb/postgraduate', require('./routes/universities/sjtu/seiee/bjwb/postgraduate'));
|
||||
router.get('/sjtu/seiee/bjwb/abroad', require('./routes/universities/sjtu/seiee/bjwb/abroad'));
|
||||
router.get('/sjtu/seiee/bjwb/international', require('./routes/universities/sjtu/seiee/bjwb/international'));
|
||||
router.get('/sjtu/seiee/xsb/:type?', require('./routes/universities/sjtu/seiee/xsb'));
|
||||
|
||||
router.get('/sjtu/gs/tzgg/:type?', require('./routes/universities/sjtu/gs/tzgg'));
|
||||
|
||||
|
||||
86
routes/universities/sjtu/seiee/xsb.js
Normal file
86
routes/universities/sjtu/seiee/xsb.js
Normal file
@@ -0,0 +1,86 @@
|
||||
const axios = require('../../../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
const url = require('url');
|
||||
|
||||
const host = 'http://xsb.seiee.sjtu.edu.cn';
|
||||
const config = {
|
||||
news: {
|
||||
link: `xsb/list/2938-1-20.htm`,
|
||||
title: '新闻发布',
|
||||
},
|
||||
scholarship: {
|
||||
link: `xsb/list/611-1-20.htm`,
|
||||
title: '奖学金',
|
||||
},
|
||||
activity: {
|
||||
link: `xsb/list/2676-1-20.htm`,
|
||||
title: '党团活动',
|
||||
},
|
||||
lecture: {
|
||||
link: `xsb/list/1981-1-20.htm`,
|
||||
title: '讲座活动',
|
||||
},
|
||||
all: {
|
||||
link: `xsb/list/705-1-20.htm`,
|
||||
title: '信息通告',
|
||||
},
|
||||
financialAid: {
|
||||
link: `xsb/list/1001-1-20.htm`,
|
||||
title: '助学金',
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
let type = ctx.params.type;
|
||||
type = type ? type : 'all';
|
||||
const link = url.resolve(host, config[type].link);
|
||||
const response = await axios.get(link);
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('.list_box_5_2 li')
|
||||
.map((i, e) => ({
|
||||
date: $(e)
|
||||
.children('span')
|
||||
.text()
|
||||
.slice(1, -1),
|
||||
title: $(e)
|
||||
.children('a')
|
||||
.text()
|
||||
.slice(1),
|
||||
link: $(e)
|
||||
.children('a')
|
||||
.attr('href'),
|
||||
}))
|
||||
.get();
|
||||
|
||||
const out = await Promise.all(
|
||||
list.map(async (item) => {
|
||||
const itemUrl = url.resolve(host, item.link);
|
||||
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: item.title,
|
||||
link: itemUrl,
|
||||
author: '上海交通大学电子信息与电气工程学院学生工作办公室',
|
||||
description: $('.article_box')
|
||||
.text()
|
||||
.slice(0, -7),
|
||||
pubDate: new Date(item.date),
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '上海交通大学电子信息与电气工程学院学生办 -- ' + config[type].title,
|
||||
link,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user