mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-12 16:20:27 +08:00
增加重庆大学教务网通知 (#662)
This commit is contained in:
@@ -2108,6 +2108,16 @@ category 列表:
|
|||||||
|
|
||||||
工作通知:无
|
工作通知:无
|
||||||
|
|
||||||
|
### 重庆大学
|
||||||
|
|
||||||
|
#### 教务网通知公告 <Author uid="El-Chiang"/>
|
||||||
|
|
||||||
|
举例: <https://rsshub.app/cqu/jwc/announcement>
|
||||||
|
|
||||||
|
路由: `/cqu/jwc/announcement`
|
||||||
|
|
||||||
|
参数: 无
|
||||||
|
|
||||||
### 成都信息工程大学
|
### 成都信息工程大学
|
||||||
|
|
||||||
#### 成信新闻网 <Author uid="kimika"/>
|
#### 成信新闻网 <Author uid="kimika"/>
|
||||||
|
|||||||
@@ -506,6 +506,9 @@ 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('/cqu/jwc/announcement', require('./routes/universities/cqu/jwc/announcement'));
|
||||||
|
|
||||||
// 成都信息工程大学
|
// 成都信息工程大学
|
||||||
router.get('/cuit/cxxww/:type?', require('./routes/universities/cuit/cxxww'));
|
router.get('/cuit/cxxww/:type?', require('./routes/universities/cuit/cxxww'));
|
||||||
|
|
||||||
|
|||||||
60
routes/universities/cqu/jwc/announcement.js
Normal file
60
routes/universities/cqu/jwc/announcement.js
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
const axios = require('../../../../utils/axios');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
|
||||||
|
const baseUrl = 'http://jwc.cqu.edu.cn';
|
||||||
|
const cacheTime = 24 * 60 * 60;
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const response = await axios({
|
||||||
|
method: 'get',
|
||||||
|
url: 'http://jwc.cqu.edu.cn/announcement',
|
||||||
|
headers: {
|
||||||
|
Referer: 'http://jwc.cqu.edu.cn/',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = response.data;
|
||||||
|
const $ = cheerio.load(data);
|
||||||
|
const links = $('.views-row a')
|
||||||
|
.slice(0, 5)
|
||||||
|
.map((index, item) => {
|
||||||
|
item = $(item);
|
||||||
|
return {
|
||||||
|
title: item.text(),
|
||||||
|
link: baseUrl + item.attr('href'),
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.get();
|
||||||
|
|
||||||
|
const items = await Promise.all(
|
||||||
|
[...links].map(async ({ title, link }) => {
|
||||||
|
const item = {
|
||||||
|
title: title,
|
||||||
|
link: link,
|
||||||
|
};
|
||||||
|
const cache = await ctx.cache.get(link);
|
||||||
|
if (cache) {
|
||||||
|
return JSON.parse(cache);
|
||||||
|
}
|
||||||
|
const response = await axios({
|
||||||
|
method: 'get',
|
||||||
|
url: link,
|
||||||
|
});
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
item.author = $('.username').text();
|
||||||
|
item.pubDate = $('time').attr('datetime');
|
||||||
|
item.description =
|
||||||
|
$('div .field-items').html() &&
|
||||||
|
$('div .field-items')
|
||||||
|
.find('p')
|
||||||
|
.text();
|
||||||
|
await ctx.cache.set(item.link, JSON.stringify(item), cacheTime);
|
||||||
|
return Promise.resolve(item);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
ctx.state.data = {
|
||||||
|
title: '重庆大学教务处通知公告',
|
||||||
|
link: 'http://jwc.cqu.edu.cn/announcement',
|
||||||
|
item: items.filter((x) => x),
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user