feat: 新增HNUST教务处通知 (#4296)

This commit is contained in:
Pretty9
2020-03-24 10:51:13 +08:00
committed by GitHub
parent 214493ae56
commit 94761c1109
3 changed files with 42 additions and 0 deletions

View File

@@ -490,6 +490,12 @@ category 列表:
</Route> </Route>
## 湖南科技大学
### 教务处通知
<Route author="Pretty9" example="/hnust/jwc" path="/hnust/jwc"/>
## 华北水利水电大学 ## 华北水利水电大学
### 学校通知 ### 学校通知

View File

@@ -2410,6 +2410,9 @@ router.get('/hubu/news/:type', require('./routes/universities/hubu/news'));
// 大连海事大学 // 大连海事大学
router.get('/dlmu/news/:type', require('./routes/universities/dlmu/news')); router.get('/dlmu/news/:type', require('./routes/universities/dlmu/news'));
// 湖南科技大学教务处
router.get('/hnust/jwc', require('./routes/universities/hnust/jwc/index'));
// AGE动漫 // AGE动漫
router.get('/agefans/detail/:id', require('./routes/agefans/detail')); router.get('/agefans/detail/:id', require('./routes/agefans/detail'));

View File

@@ -0,0 +1,33 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const base = 'http://jwc.hnust.edu.cn/gzzd2_20170827120536008171/jwk3_20170827120536008171/';
const link = 'http://jwc.hnust.edu.cn/gzzd2_20170827120536008171/jwk3_20170827120536008171/index.htm';
const response = await got.get(link);
const $ = cheerio.load(response.data);
const list = $('.articleList ul li');
ctx.state.data = {
title: '湖南科技大学教务处通知',
link: link,
description: '湖南科技大学教务处通知',
item:
list &&
list
.map((index, item) => {
item = $(item);
const date = item.find('span').text();
const title = item.find('a').text();
const url = base + item.find('a').attr('href');
return {
title: title,
description: title,
pubDate: new Date(date).toUTCString(),
link: url,
};
})
.get(),
};
};