feat(route): add添加海南大学研究生招生动态 (#7608)

This commit is contained in:
Odin Zhang 2021-06-11 14:23:17 +08:00 committed by GitHub
parent 5369dbf7dc
commit e2b1df989b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 0 deletions

View File

@ -2342,3 +2342,9 @@ type 列表:
### 数据科学与计算机学院动态
<Route author="Neutrino3316 MegrezZhu" example="/sysu/sdcs" path="/sysu/sdcs" />
## 海南大学
### 硕士研究生招生动态
<Route author="OdinZhang" example="/hainanu/ssszs" path="hainanu/ssszs"/>

View File

@ -4097,4 +4097,7 @@ router.get('/tongli/news/:type', require('./routes/tongli/news'));
// OR
router.get('/or/:id?', require('./routes/or'));
// 海南大学
router.get('/hainanu/ssszs', require('./routes/hainanu/ssszs'));
module.exports = router;

View File

@ -0,0 +1,36 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const url = 'https://ha.hainanu.edu.cn/gs/yjszs/ssszs.htm';
const response = await got({
method: 'get',
url,
});
const data = response.data;
const $ = cheerio.load(data);
const list = $('.m_new13>ul>li');
ctx.state.data = {
title: '海南大学研究生招生',
link: url,
description: '海南大学研究生招生公告',
item:
list &&
list
.map((index, item) => {
item = $(item);
const date = item.find('span').text();
const pubDate = parseDate(date, 'YYYY-MM-DD');
return {
title: item.find('a').text(),
link: item.find('a').attr('href'),
pubDate,
};
})
.get(),
};
};