mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 23:00:48 +08:00
feat: add 重庆大学校团委 (#4832)
This commit is contained in:
@@ -1774,6 +1774,16 @@ type 列表:
|
||||
|
||||
<Route author="nicolaszf" example="/cqu/news/jzyg" path="/cqu/news/jzyg"/>
|
||||
|
||||
### 校团委
|
||||
|
||||
<Route author="Hagb" example="/cqu/youth/gzdt" path="/cqu/youth/:category" :paramsDesc="['分类名']">
|
||||
|
||||
| 工作动态 | 院系风采 | 通知公告(可能需内网) | 文件转载 |
|
||||
| -------- | -------- | ---------------------- | -------- |
|
||||
| gzdt | yxfc | tzgg | wjzz |
|
||||
|
||||
</Route>
|
||||
|
||||
## 重庆科技学院
|
||||
|
||||
### 教务处公告
|
||||
|
||||
@@ -661,6 +661,7 @@ router.get('/heu/job/:type?', require('./routes/universities/heu/job'));
|
||||
// 重庆大学
|
||||
router.get('/cqu/jwc/announcement', require('./routes/universities/cqu/jwc/announcement'));
|
||||
router.get('/cqu/news/jzyg', require('./routes/universities/cqu/news/jzyg'));
|
||||
router.get('/cqu/youth/:category', require('./routes/universities/cqu/youth/info'));
|
||||
|
||||
// 南京信息工程大学
|
||||
router.get('/nuist/bulletin/:category?', require('./routes/universities/nuist/bulletin'));
|
||||
|
||||
61
lib/routes/universities/cqu/youth/info.js
Normal file
61
lib/routes/universities/cqu/youth/info.js
Normal file
@@ -0,0 +1,61 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category;
|
||||
|
||||
const baseUrl = 'http://youth.cqu.edu.cn/index/';
|
||||
const url = `http://youth.cqu.edu.cn/index/${category}.htm`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: url,
|
||||
});
|
||||
|
||||
const data = response.data;
|
||||
const $ = cheerio.load(data);
|
||||
|
||||
const links = $('div[class=nwes_list]')
|
||||
.find('ul[style]') // nwes_list 原文如此
|
||||
.find('a[target=_blank]')
|
||||
.map((index, item) => ({
|
||||
title: item.attribs.title,
|
||||
link: baseUrl + item.attribs.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 got({
|
||||
method: 'get',
|
||||
url: link,
|
||||
});
|
||||
const newsContent = cheerio.load(response.data)('form[name=_newscontent_fromname]');
|
||||
|
||||
const [dateText, authorText] = newsContent.find('div[align=center]').text().split(/\xA0+/, 2); // \xA0+:
|
||||
|
||||
item.pubDate = dateText.replace(/ /, 'T') + '+08:00';
|
||||
if (authorText && authorText.slice(0, 4) === '拟稿人:') {
|
||||
item.author = authorText.slice(4);
|
||||
}
|
||||
item.description = newsContent.find('div[class=v_news_content]').find('div').text();
|
||||
|
||||
ctx.cache.set(item.link, JSON.stringify(item));
|
||||
return Promise.resolve(item);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: url,
|
||||
description: $.title,
|
||||
item: items.filter((x) => x),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user