feat: add 重庆大学信息化办公室 (#4965)
This commit is contained in:
@@ -1815,6 +1815,16 @@ type 列表:
|
||||
|
||||
</Route>
|
||||
|
||||
### 信息化办公室
|
||||
|
||||
<Route author="Hagb" example="/cqu/net/tzgg" path="/cqu/net/:category" :paramsDesc="['分类名']">
|
||||
|
||||
| 通知公告 | 单位动态 | 语言文字 |
|
||||
| -------- | -------- | -------- |
|
||||
| tzgg | dwdt | yywz |
|
||||
|
||||
</Route>
|
||||
|
||||
## 重庆科技学院
|
||||
|
||||
### 教务处公告
|
||||
|
||||
@@ -668,6 +668,7 @@ router.get('/cqu/jwc/announcement', require('./routes/universities/cqu/jwc/annou
|
||||
router.get('/cqu/news/jzyg', require('./routes/universities/cqu/news/jzyg'));
|
||||
router.get('/cqu/youth/:category', require('./routes/universities/cqu/youth/info'));
|
||||
router.get('/cqu/sci/:category', require('./routes/universities/cqu/sci/info'));
|
||||
router.get('/cqu/net/:category', require('./routes/universities/cqu/net/info'));
|
||||
|
||||
// 南京信息工程大学
|
||||
router.get('/nuist/bulletin/:category?', require('./routes/universities/nuist/bulletin'));
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category;
|
||||
|
||||
const baseUrl = `http://net.cqu.edu.cn/index/`;
|
||||
const url = `http://net.cqu.edu.cn/index/${category}.htm`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: url,
|
||||
});
|
||||
|
||||
const data = response.data;
|
||||
const $ = cheerio.load(data);
|
||||
|
||||
const links = $('li[id]', 'div[class=index]')
|
||||
.find('p[class=detail]', 'a[href]')
|
||||
.map((index, item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.text(),
|
||||
link: baseUrl + item.parent().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 got({
|
||||
method: 'get',
|
||||
url: link,
|
||||
});
|
||||
const newsContent = cheerio.load(response.data)('form[name=_newscontent_fromname]');
|
||||
const dateP = newsContent.find('h1', 'div[class=cont]').nextAll().filter('p');
|
||||
|
||||
const date = dateP.text().match(/日期:(\d{4})年(\d\d)月(\d\d)日/);
|
||||
item.pubDate = `${date[1]}-${date[2]}-${date[3]}T00:00+08:00`;
|
||||
item.description = newsContent.find('div[class=v_news_content]', 'div[class=contentd]').html();
|
||||
|
||||
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