feat: add 合肥工业大学通知公告 (#5286)

This commit is contained in:
log-e 2020-07-29 21:39:11 +08:00 committed by GitHub
parent ee5bee804d
commit c76af92362
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 0 deletions

View File

@ -595,6 +595,12 @@ category 列表:
<Route author="raptazure" example="/hitwh/today" path="hitwh/today" />
## 合肥工业大学
### 通知公告
<Route author="log-e" example="/hfut/tzgg" path="/hfut/tzgg"/>
## 河海大学
### 河海大学图书馆 - 新闻动态

View File

@ -3025,6 +3025,9 @@ router.get('/jlu/oa', require('./routes/universities/jlu/oa'));
// 小宇宙
router.get('/xiaoyuzhou', require('./routes/xiaoyuzhou/pickup'));
// 合肥工业大学
router.get('/hfut/tzgg', require('./routes/universities/hfut/tzgg'));
// Darwin Awards
router.get('/darwinawards/all', require('./routes/darwinawards/articles'));

View File

@ -0,0 +1,25 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const baseUrl = 'http://news.hfut.edu.cn/tzgg.htm';
const response = await got({
method: 'get',
url: baseUrl,
});
const data = response.data;
const $ = cheerio.load(data);
ctx.state.data = {
link: baseUrl,
title: $('title').text(),
item: $('body > div.list.wrap > div > ul > li')
.slice(0, 10)
.map((_, elem) => ({
title: $('a', elem).attr('title'),
link: $('a', elem).attr('href'),
pubDate: new Date($('a > i', elem).text().replace('年', '-').replace('月', '-').replace('日', '')),
}))
.get(),
};
};