mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 14:40:23 +08:00
feat: add 中国海洋大学 信息学院通知 (#3990)
This commit is contained in:
@@ -1189,6 +1189,18 @@ https://rsshub.app/**nuist**/`bulletin` 或 https://rsshub.app/**nuist**/`bullet
|
||||
|
||||
<Route author="sanmmm" example="/cug/graduate" path="/cug/graduate" />
|
||||
|
||||
## 中国海洋大学
|
||||
|
||||
### 信息科学与工程学院
|
||||
|
||||
<Route author="Geo" example="/ouc/it/0" path="/universities/ouc/it/:type?" :paramsDesc="['默认为 `0`']">
|
||||
|
||||
| 学院要闻 | 学院公告 | 学院活动 |
|
||||
| -------- | -------- | -------- |
|
||||
| 0 | 1 | 2 |
|
||||
|
||||
</Route>
|
||||
|
||||
## 中国科学院
|
||||
|
||||
### 上海微系统与信息技术研究所学术活动
|
||||
|
||||
@@ -695,6 +695,9 @@ router.get('/sdu/cmse/:type?', require('./routes/universities/sdu/cmse'));
|
||||
router.get('/sdu/mech/:type?', require('./routes/universities/sdu/mech'));
|
||||
router.get('/sdu/epe/:type?', require('./routes/universities/sdu/epe'));
|
||||
|
||||
// 中国海洋大学
|
||||
router.get('/ouc/it/:type?', require('./routes/universities/ouc/it'));
|
||||
|
||||
// 大连大学
|
||||
router.get('/dlu/jiaowu/news', require('./routes/universities/dlu/jiaowu/news'));
|
||||
|
||||
|
||||
54
lib/routes/universities/ouc/it.js
Normal file
54
lib/routes/universities/ouc/it.js
Normal file
@@ -0,0 +1,54 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const url = require('url');
|
||||
|
||||
const host = 'https://it.ouc.edu.cn/';
|
||||
const typelist = ['学院要闻', '学院公告', '学术活动'];
|
||||
const urlList = ['xyyw/list.psp', 'xygg/list.psp', 'xshd/list.psp'];
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const type = parseInt(ctx.params.type) || 0;
|
||||
const link = url.resolve(host, urlList[type]);
|
||||
const response = await got.get(link);
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const dateDict = {};
|
||||
const list = $('#wp_news_w33')
|
||||
.find('li')
|
||||
.slice(0, 9)
|
||||
.map((i, e) => {
|
||||
const divs = $(e).children();
|
||||
const tlink = host + divs.find('a')[0].attribs.href.substring(1);
|
||||
dateDict[tlink] = new Date($($(divs.children()[0]).find('p')[0]).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 got.get(itemUrl);
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const single = {
|
||||
title: $('.content-tittle')
|
||||
.text()
|
||||
.trim(),
|
||||
author: '中国海洋大学信息科学与工程学院',
|
||||
description: $('.wp_articlecontent').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