mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-07 13:39:35 +08:00
feat: 添加山东大学计算机科学与技术学院 RSS (#2267)
* 添加山东大学计算机科学与技术学院通知 * 添加山东大学计算机科学与技术学院通知 * add .toUTCString()
This commit is contained in:
@@ -632,6 +632,16 @@ https://rsshub.app/**nuist**/`bulletin` 或 https://rsshub.app/**nuist**/`bullet
|
|||||||
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
### 计算机科学与技术学院通知
|
||||||
|
|
||||||
|
<Route author="suxb201" example="/sdu/cs/0" path="/universities/sdu/cs/:type?" :paramsDesc="['默认为 `0`']">
|
||||||
|
|
||||||
|
| 学院公告 | 学术报告 | 新闻动态 |
|
||||||
|
| -------- | -------- | -------- |
|
||||||
|
| 0 | 1 | 2 |
|
||||||
|
|
||||||
|
</Route>
|
||||||
|
|
||||||
## 上海大学
|
## 上海大学
|
||||||
|
|
||||||
### 上海大学教务处通知公告
|
### 上海大学教务处通知公告
|
||||||
|
|||||||
@@ -635,6 +635,7 @@ router.get('/hust/aia/notice/:type?', require('./routes/universities/hust/aia/no
|
|||||||
// 山东大学
|
// 山东大学
|
||||||
router.get('/sdu/grad/academic', require('./routes/universities/sdu/grad/academic'));
|
router.get('/sdu/grad/academic', require('./routes/universities/sdu/grad/academic'));
|
||||||
router.get('/sdu/sc/:type?', require('./routes/universities/sdu/sc'));
|
router.get('/sdu/sc/:type?', require('./routes/universities/sdu/sc'));
|
||||||
|
router.get('/sdu/cs/:type?', require('./routes/universities/sdu/cs'));
|
||||||
router.get('/sdu/cmse/:type?', require('./routes/universities/sdu/cmse'));
|
router.get('/sdu/cmse/:type?', require('./routes/universities/sdu/cmse'));
|
||||||
router.get('/sdu/mech/:type?', require('./routes/universities/sdu/mech'));
|
router.get('/sdu/mech/:type?', require('./routes/universities/sdu/mech'));
|
||||||
router.get('/sdu/epe/:type?', require('./routes/universities/sdu/epe'));
|
router.get('/sdu/epe/:type?', require('./routes/universities/sdu/epe'));
|
||||||
|
|||||||
61
lib/routes/universities/sdu/cs.js
Normal file
61
lib/routes/universities/sdu/cs.js
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
const axios = require('@/utils/axios');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const url = require('url');
|
||||||
|
|
||||||
|
const host = 'http://www.cs.sdu.edu.cn/';
|
||||||
|
const typelist = ['学院公告', '学术报告', '新闻动态'];
|
||||||
|
const urlList = ['index/xygg.htm', 'xwgg/xsbg.htm', 'xwgg/xyxw.htm'];
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const type = parseInt(ctx.params.type) || 0;
|
||||||
|
const link = url.resolve(host, urlList[type]);
|
||||||
|
|
||||||
|
const response = await axios.get(link);
|
||||||
|
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
|
||||||
|
const dateDict = {};
|
||||||
|
const list = $('.sub_text .news-list')
|
||||||
|
.slice(0, 10)
|
||||||
|
.map((i, e) => {
|
||||||
|
const divs = $(e).children();
|
||||||
|
const tlink =
|
||||||
|
'http://www.cs.sdu.edu.cn/' +
|
||||||
|
$('a', divs[1])
|
||||||
|
.attr('href')
|
||||||
|
.substring(3);
|
||||||
|
dateDict[tlink] = new Date($(divs[2]).text()).toUTCString();
|
||||||
|
return tlink;
|
||||||
|
})
|
||||||
|
.get();
|
||||||
|
|
||||||
|
const out = await Promise.all(
|
||||||
|
list.map(async (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: $('#newsTitle')
|
||||||
|
.text()
|
||||||
|
.trim(),
|
||||||
|
author: '山东大学计算机科学与技术学院',
|
||||||
|
description: $('.v_news_content').html(),
|
||||||
|
pubDate: dateDict[itemUrl],
|
||||||
|
link: itemUrl,
|
||||||
|
};
|
||||||
|
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||||
|
return Promise.resolve(single);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: `山东大学计算机科学与技术学院${typelist[type]}通知`,
|
||||||
|
link,
|
||||||
|
item: out,
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user