mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 22:19:40 +08:00
feat: add zzu news and fix doc error (#3597)
This commit is contained in:
@@ -276,7 +276,7 @@ sidebar: auto
|
||||
4. **使用通用配置型路由**
|
||||
|
||||
很大一部分网站是可以通过一个配置范式来生成 RSS 的。
|
||||
通用配置即通过 cherrio(**CSS 选择器、jQuery 函数**)读取 json 数据来简便的生成 RSS。
|
||||
通用配置即通过 cheerio(**CSS 选择器、jQuery 函数**)读取 json 数据来简便的生成 RSS。
|
||||
|
||||
首先我们需要几个数据:
|
||||
|
||||
|
||||
@@ -1047,6 +1047,28 @@ https://rsshub.app/**nuist**/`bulletin` 或 https://rsshub.app/**nuist**/`bullet
|
||||
|
||||
</Route>
|
||||
|
||||
## 郑州大学
|
||||
|
||||
### 郑州大学新闻网
|
||||
|
||||
<Route author="niayyy-S" example="/zzu/news/zh" path="zzu/news/:type?" :paramsDesc="['可选, 默认为 `zh`']">
|
||||
|
||||
| 参数名称 | 综合新闻 | 学术动态 | 媒体郑大 | 院系风采 | 教学科研 | 学生信息 | 外事信息 |
|
||||
| -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |
|
||||
| 参数 | zh | xs | mt | yx | ky | stu | ws |
|
||||
|
||||
</Route>
|
||||
|
||||
### 软件学院
|
||||
|
||||
<Route author="niayyy-S" example="/zzu/soft/news/xyxw" path="zzu/soft/news/:type?" :paramsDesc="['可选, 默认为 `xyxw`']">
|
||||
|
||||
| 参数名称 | 学院新闻 | 学院公告 | 学生工作 |
|
||||
| -------- | -------- | -------- | -------- |
|
||||
| 参数 | xyxw | xygg | xsgz |
|
||||
|
||||
</Route>
|
||||
|
||||
## 中国传媒大学
|
||||
|
||||
### 中国传媒大学研究生招生网
|
||||
|
||||
@@ -627,6 +627,10 @@ router.get('/nuist/cas/:category?', require('./routes/universities/nuist/cas'));
|
||||
// 成都信息工程大学
|
||||
router.get('/cuit/cxxww/:type?', require('./routes/universities/cuit/cxxww'));
|
||||
|
||||
// 郑州大学
|
||||
router.get('/zzu/news/:type', require('./routes/universities/zzu/news'));
|
||||
router.get('/zzu/soft/news/:type', require('./routes/universities/zzu/soft/news'));
|
||||
|
||||
// 重庆科技学院
|
||||
router.get('/cqust/jw/:type?', require('./routes/universities/cqust/jw'));
|
||||
router.get('/cqust/lib/:type?', require('./routes/universities/cqust/lib'));
|
||||
|
||||
90
lib/routes/universities/zzu/news.js
Normal file
90
lib/routes/universities/zzu/news.js
Normal file
@@ -0,0 +1,90 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
const config = {
|
||||
xs: {
|
||||
title: '学术动态',
|
||||
url: 'http://www16.zzu.edu.cn/msgs/vmsgisapi.dll/vmsglist?mtype=x&lan=205',
|
||||
},
|
||||
mt: {
|
||||
title: '媒体郑大',
|
||||
url: 'http://www16.zzu.edu.cn/msgs/vmsgisapi.dll/vmsglist?mtype=x&lan=208',
|
||||
},
|
||||
zh: {
|
||||
title: '综合新闻',
|
||||
url: 'http://www16.zzu.edu.cn/msgs/vmsgisapi.dll/vmsglist?mtype=x&lan=202',
|
||||
},
|
||||
yx: {
|
||||
title: '院系风采',
|
||||
url: 'http://www16.zzu.edu.cn/msgs/vmsgisapi.dll/vmsglist?mtype=x&lan=206',
|
||||
},
|
||||
ky: {
|
||||
title: '教学科研',
|
||||
url: 'http://www16.zzu.edu.cn/msgs/vmsgisapi.dll/vmsglist?mtype=x&lan=203',
|
||||
},
|
||||
stu: {
|
||||
title: '学生信息',
|
||||
url: 'http://www16.zzu.edu.cn/msgs/vmsgisapi.dll/vmsglist?mtype=x&lan=204',
|
||||
},
|
||||
ws: {
|
||||
title: '外事信息',
|
||||
url: 'http://www16.zzu.edu.cn/msgs/vmsgisapi.dll/vmsglist?mtype=x&lan=209',
|
||||
},
|
||||
};
|
||||
async function getNewsDetail(link) {
|
||||
const res = await got.get(link);
|
||||
const $ = cheerio.load(res.data);
|
||||
return {
|
||||
author: $('.zzj_4 .zzj_f2')
|
||||
.eq(1)
|
||||
.text(),
|
||||
pubDate: new Date(
|
||||
$('.zzj_4 .zzj_f2')
|
||||
.eq(2)
|
||||
.text()
|
||||
).toUTCString(),
|
||||
description: $('.zzj_5').html(),
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const type = ctx.params.type || 'zh';
|
||||
const url = config[type].url;
|
||||
const title = config[type].title;
|
||||
|
||||
const res = await got.get(url);
|
||||
const $ = cheerio.load(res.data);
|
||||
|
||||
const out = await Promise.all(
|
||||
$('.zzj_5 .zzj_5a')
|
||||
.slice(0, 10)
|
||||
.map(async (i, v) => {
|
||||
const link = $(v)
|
||||
.find('a')
|
||||
.attr('href');
|
||||
const title = $(v)
|
||||
.find('.zzj_f6_c')
|
||||
.text();
|
||||
const single = {
|
||||
title,
|
||||
link,
|
||||
};
|
||||
let other = {};
|
||||
const cache = await ctx.cache.get(link);
|
||||
if (cache) {
|
||||
other = JSON.parse(cache);
|
||||
} else {
|
||||
other = await getNewsDetail(link);
|
||||
ctx.cache.set(link, JSON.stringify(other));
|
||||
}
|
||||
|
||||
return Promise.resolve(Object.assign({}, single, other));
|
||||
})
|
||||
.get()
|
||||
);
|
||||
ctx.state.data = {
|
||||
title: `郑州大学新闻网 -- ${title}`,
|
||||
link: 'http://news.zzu.edu.cn/',
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
78
lib/routes/universities/zzu/soft/news.js
Normal file
78
lib/routes/universities/zzu/soft/news.js
Normal file
@@ -0,0 +1,78 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
const config = {
|
||||
xyxw: {
|
||||
title: '学院新闻',
|
||||
url: 'http://www5.zzu.edu.cn/soft/xyxw.htm',
|
||||
},
|
||||
|
||||
xygg: {
|
||||
title: '学院公告',
|
||||
url: 'http://www5.zzu.edu.cn/soft/xygg.htm',
|
||||
},
|
||||
|
||||
xsgz: {
|
||||
title: '学生工作',
|
||||
url: 'http://www5.zzu.edu.cn/soft/xsgz.htm',
|
||||
},
|
||||
};
|
||||
async function getNewsDetail(link) {
|
||||
const res = await got.get(link);
|
||||
const $ = cheerio.load(res.data);
|
||||
return {
|
||||
author: '软件学院',
|
||||
description: $('.article_content').html(),
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const type = ctx.params.type || 'xyxw';
|
||||
const url = config[type].url;
|
||||
const title = config[type].title;
|
||||
const BaseURL = 'http://www5.zzu.edu.cn/soft/';
|
||||
|
||||
const res = await got.get(url);
|
||||
const $ = cheerio.load(res.data);
|
||||
|
||||
const out = await Promise.all(
|
||||
$('.list .span8')
|
||||
.slice(0, 10)
|
||||
.map(async (i, v) => {
|
||||
const link =
|
||||
BaseURL +
|
||||
$(v)
|
||||
.find('a')
|
||||
.attr('href');
|
||||
const title = $(v)
|
||||
.find('a')
|
||||
.text();
|
||||
const pubDate = new Date(
|
||||
$(v)
|
||||
.find('.fr')
|
||||
.text()
|
||||
).toUTCString();
|
||||
const single = {
|
||||
link,
|
||||
title,
|
||||
pubDate,
|
||||
};
|
||||
let other = {};
|
||||
const cache = await ctx.cache.get(link);
|
||||
if (cache) {
|
||||
other = JSON.parse(cache);
|
||||
} else {
|
||||
other = await getNewsDetail(link);
|
||||
ctx.cache.set(link, JSON.stringify(other));
|
||||
}
|
||||
|
||||
return Promise.resolve(Object.assign({}, single, other));
|
||||
})
|
||||
.get()
|
||||
);
|
||||
ctx.state.data = {
|
||||
title: `郑州大学软件学院 -- ${title}`,
|
||||
link: 'http://www5.zzu.edu.cn/soft/index.htm',
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user