mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 14:40:23 +08:00
feat:增加上海大学教务处官网公告RSS源 (#1618)
This commit is contained in:
@@ -1893,6 +1893,16 @@ https://rsshub.app/**nuist**/`bulletin` 或 https://rsshub.app/**nuist**/`bullet
|
||||
|
||||
</route>
|
||||
|
||||
### 上海大学
|
||||
|
||||
<route name="上海大学教务处通知公告" author="tuxinghuan" example="shu/jwc/notice" path="/university/shu/jwc/:type?" :paramsDesc="['消息类型,默认为`notice`']">
|
||||
|
||||
| 通知通告 | 新闻 |
|
||||
| -------- | ---- |
|
||||
| notice | news |
|
||||
|
||||
</route>
|
||||
|
||||
### 同济大学
|
||||
|
||||
<route name="同济大学软件学院通知" author="sgqy" example="/tju/sse/xwdt" path="/tju/sse/:type?" :paramsDesc="['通知类型. 默认为 `xwdt`']">
|
||||
|
||||
@@ -699,6 +699,9 @@ router.get('/nku/jwc/:type?', require('./routes/universities/nku/jwc/index'));
|
||||
// 北京航空航天大学
|
||||
router.get('/buaa/news/:type', require('./routes/universities/buaa/news/index'));
|
||||
|
||||
// 上海大学
|
||||
router.get('/shu/jwc/:type?', require('./routes/universities/shu/jwc'));
|
||||
|
||||
// ifanr
|
||||
router.get('/ifanr/:channel?', require('./routes/ifanr/index'));
|
||||
|
||||
|
||||
75
lib/routes/universities/shu/jwc.js
Normal file
75
lib/routes/universities/shu/jwc.js
Normal file
@@ -0,0 +1,75 @@
|
||||
const axios = require('../../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
const url = require('url');
|
||||
|
||||
const host = 'http://www.jwc.shu.edu.cn';
|
||||
|
||||
const config = {
|
||||
notice: {
|
||||
link: 'http://www.jwc.shu.edu.cn/index/tzgg.htm',
|
||||
type: 'notice',
|
||||
title: '通知通告',
|
||||
},
|
||||
news: {
|
||||
link: 'http://www.jwc.shu.edu.cn/index/xw.htm',
|
||||
type: 'news',
|
||||
title: '新闻',
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
let type = ctx.params.type;
|
||||
type = type ? type : 'notice';
|
||||
const link = type === 'news' ? config.news.link : config.notice.link;
|
||||
const title = type === 'news' ? config.news.title : config.notice.title;
|
||||
const respond = await axios.get(link);
|
||||
const $ = cheerio.load(respond.data);
|
||||
const list = $('#dnn_ctr43516_ArticleList__ctl0_ArtDataList__ctl1_titleLink1')
|
||||
.map(function(index, ele) {
|
||||
return {
|
||||
title: $(ele).attr('title'),
|
||||
link: $(ele).attr('href'),
|
||||
date: $('#dnn_ctr43465_ArtDetail_lblDatePosted').text(),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const all = 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 respond = await axios.get(itemUrl);
|
||||
const $ = cheerio.load(respond.data);
|
||||
const single = {
|
||||
title: item.title,
|
||||
link: itemUrl,
|
||||
author: $('.normal')
|
||||
.next()
|
||||
.text()
|
||||
.trim()
|
||||
.slice(0, -3),
|
||||
guid: itemUrl,
|
||||
pubDate: new Date(
|
||||
new Date(
|
||||
...$('.normal')
|
||||
.text()
|
||||
.slice(0, 10)
|
||||
.split('-')
|
||||
).getTime() -
|
||||
60 * 60 * 24 * 30 * 1000
|
||||
).toUTCString(),
|
||||
description: item.title,
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
ctx.state.data = {
|
||||
title: '上海大学教务处--' + title,
|
||||
link: 'http://www.jwc.shu.edu.cn/index.htm',
|
||||
item: all,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user