mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 14:40:23 +08:00
feat: add 哈尔滨工程大学:水声工程学院-新闻动态 and 通知公告 及其相关radar (#4136)
This commit is contained in:
@@ -1357,4 +1357,52 @@
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
'hrbeu.edu.cn': {
|
||||||
|
_name: '哈尔滨工程大学',
|
||||||
|
yjsy: [
|
||||||
|
{
|
||||||
|
title: '研究生院 - 通知公告',
|
||||||
|
docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue',
|
||||||
|
source: '/*',
|
||||||
|
target: '/heu/yjsy/announcement',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '研究生院 - 新闻动态',
|
||||||
|
docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue',
|
||||||
|
source: '/*',
|
||||||
|
target: '/heu/yjsy/news',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
uae: [
|
||||||
|
{
|
||||||
|
title: '水声学院 - 新闻动态',
|
||||||
|
docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue',
|
||||||
|
source: '/*',
|
||||||
|
target: '/heu/shuisheng/xwdt',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '研究生院 - 通知公告',
|
||||||
|
docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue',
|
||||||
|
source: '/*',
|
||||||
|
target: '/heu/shuisheng/tzgg',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
'gongxue.cn': {
|
||||||
|
_name: '工学网',
|
||||||
|
'.': [
|
||||||
|
{
|
||||||
|
title: '要闻',
|
||||||
|
docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue',
|
||||||
|
source: '/*',
|
||||||
|
target: '/heu/gongxue/yw',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '时讯',
|
||||||
|
docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue',
|
||||||
|
source: '/*',
|
||||||
|
target: '/heu/gongxue/sx',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -387,7 +387,7 @@ category 列表:
|
|||||||
|
|
||||||
### 研究生院
|
### 研究生院
|
||||||
|
|
||||||
<Route author="XYenon" example="/heu/yjsy/announcement" path="/heu/yjsy/:type?" :paramsDesc="['分类, 默认为 `announcement`']">
|
<Route author="XYenon" example="/heu/yjsy/announcement" path="/heu/yjsy/:type?" :paramsDesc="['分类, 默认为 `announcement`']" radar="1">
|
||||||
|
|
||||||
| 通知公告 | 新闻动态 |
|
| 通知公告 | 新闻动态 |
|
||||||
| ------------ | -------- |
|
| ------------ | -------- |
|
||||||
@@ -397,7 +397,7 @@ category 列表:
|
|||||||
|
|
||||||
### 工学网
|
### 工学网
|
||||||
|
|
||||||
<Route author="Derekmini XYenon" example="/heu/gongxue/yw" path="/heu/gongxue/:type?" :paramsDesc="['分类, 默认为 `yw`']">
|
<Route author="Derekmini XYenon" example="/heu/gongxue/yw" path="/heu/gongxue/:type?" :paramsDesc="['分类, 默认为 `yw`']" radar="1">
|
||||||
|
|
||||||
| 要闻 | 时讯 |
|
| 要闻 | 时讯 |
|
||||||
| ---- | ---- |
|
| ---- | ---- |
|
||||||
@@ -405,6 +405,16 @@ category 列表:
|
|||||||
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
### 水声工程学院通知
|
||||||
|
|
||||||
|
<Route author="Derekmini" example="/heu/shuisheng/xwdt" path="/heu/shuisheng/:type?" :paramsDesc="['分类, 默认为 `xwdt`']" radar="1">
|
||||||
|
|
||||||
|
| 新闻动态 | 通知公告 |
|
||||||
|
| -------- | -------- |
|
||||||
|
| xwdt | tzgg |
|
||||||
|
|
||||||
|
</Route>
|
||||||
|
|
||||||
## 哈尔滨工业大学
|
## 哈尔滨工业大学
|
||||||
|
|
||||||
### 哈尔滨工业大学教务处通知公告
|
### 哈尔滨工业大学教务处通知公告
|
||||||
|
|||||||
@@ -623,6 +623,7 @@ router.get('/nchu/jwc/:type?', require('./routes/universities/nchu/jwc'));
|
|||||||
router.get('/heu/ugs/news/:author?/:category?', require('./routes/universities/heu/ugs/news'));
|
router.get('/heu/ugs/news/:author?/:category?', require('./routes/universities/heu/ugs/news'));
|
||||||
router.get('/heu/yjsy/:type?', require('./routes/universities/heu/yjsy'));
|
router.get('/heu/yjsy/:type?', require('./routes/universities/heu/yjsy'));
|
||||||
router.get('/heu/gongxue/:type?', require('./routes/universities/heu/gongxue'));
|
router.get('/heu/gongxue/:type?', require('./routes/universities/heu/gongxue'));
|
||||||
|
router.get('/heu/shuisheng/:type?', require('./routes/universities/heu/shuisheng'));
|
||||||
|
|
||||||
// 重庆大学
|
// 重庆大学
|
||||||
router.get('/cqu/jwc/announcement', require('./routes/universities/cqu/jwc/announcement'));
|
router.get('/cqu/jwc/announcement', require('./routes/universities/cqu/jwc/announcement'));
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ module.exports = async (ctx) => {
|
|||||||
|
|
||||||
const out = await Promise.all(
|
const out = await Promise.all(
|
||||||
urlList.map(async (itemUrl, index) => {
|
urlList.map(async (itemUrl, index) => {
|
||||||
|
const itemYear = itemUrl.substring(6, 10);
|
||||||
itemUrl = url.resolve(baseUrl, itemUrl);
|
itemUrl = url.resolve(baseUrl, itemUrl);
|
||||||
if (itemUrl.indexOf('.html') !== -1) {
|
if (itemUrl.indexOf('.html') !== -1) {
|
||||||
const cache = await ctx.cache.get(itemUrl);
|
const cache = await ctx.cache.get(itemUrl);
|
||||||
@@ -64,7 +65,7 @@ module.exports = async (ctx) => {
|
|||||||
title: titleList[index],
|
title: titleList[index],
|
||||||
link: itemUrl,
|
link: itemUrl,
|
||||||
description: $('.wenzhangzhengwen').html(),
|
description: $('.wenzhangzhengwen').html(),
|
||||||
pubDate: '2020-' + dateList[index],
|
pubDate: itemYear + '-' + dateList[index],
|
||||||
};
|
};
|
||||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||||
return Promise.resolve(single);
|
return Promise.resolve(single);
|
||||||
|
|||||||
84
lib/routes/universities/heu/shuisheng.js
Normal file
84
lib/routes/universities/heu/shuisheng.js
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const url = require('url');
|
||||||
|
|
||||||
|
const baseUrl = 'http://uae.hrbeu.edu.cn';
|
||||||
|
|
||||||
|
const typeMap = {
|
||||||
|
xwdt: {
|
||||||
|
name: '新闻动态',
|
||||||
|
url: '/3751/list.htm',
|
||||||
|
},
|
||||||
|
tzgg: {
|
||||||
|
name: '通知公告',
|
||||||
|
url: '/3752/list.htm',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const type = ctx.params.type || 'tzgg';
|
||||||
|
const link = baseUrl + typeMap[type].url;
|
||||||
|
const response = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: link,
|
||||||
|
headers: {
|
||||||
|
Referer: baseUrl,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
|
||||||
|
const urlList = $('.column-news-item')
|
||||||
|
.slice(0, 10)
|
||||||
|
.map((i, e) => $(e).attr('href'))
|
||||||
|
.get();
|
||||||
|
|
||||||
|
const titleList = $('.column-news-item')
|
||||||
|
.slice(0, 10)
|
||||||
|
.map((i, e) => $('.column-news-title', e).text())
|
||||||
|
.get();
|
||||||
|
|
||||||
|
const dateList = $('.column-news-item')
|
||||||
|
.slice(0, 10)
|
||||||
|
.map((i, e) => $('.column-news-date', e).text())
|
||||||
|
.get();
|
||||||
|
|
||||||
|
const out = await Promise.all(
|
||||||
|
urlList.map(async (itemUrl, index) => {
|
||||||
|
itemUrl = url.resolve(baseUrl, itemUrl);
|
||||||
|
if (itemUrl.indexOf('.htm') !== -1) {
|
||||||
|
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: titleList[index],
|
||||||
|
link: itemUrl,
|
||||||
|
description: $('.wp_articlecontent')
|
||||||
|
.html()
|
||||||
|
.replace(/src="\//g, `src="${url.resolve(baseUrl, '.')}`)
|
||||||
|
.replace(/href="\//g, `href="${url.resolve(baseUrl, '.')}`)
|
||||||
|
.trim(),
|
||||||
|
pubDate: dateList[index],
|
||||||
|
};
|
||||||
|
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||||
|
return Promise.resolve(single);
|
||||||
|
} else {
|
||||||
|
const single = {
|
||||||
|
title: titleList[index],
|
||||||
|
link: itemUrl,
|
||||||
|
description: '此链接为文件,请点击下载',
|
||||||
|
pubDate: dateList[index],
|
||||||
|
};
|
||||||
|
return Promise.resolve(single);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: '水声工程学院-' + typeMap[type].name,
|
||||||
|
link: link,
|
||||||
|
item: out,
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user