feat: Add 南京林业大学教务处 (#3836)

This commit is contained in:
Kyouya
2020-02-01 17:18:10 +08:00
committed by GitHub
parent 4d0f93db14
commit eae077c58c
3 changed files with 59 additions and 0 deletions

View File

@@ -606,6 +606,18 @@ category 列表:
</Route>
## 南京林业大学
### 教务处
<Route author="kiusiudeng" example="/njfu/jwc/1798" path="/universities/njfu/jwc/:category?" :paramsDesc="['省略则默认为1799']">
| 校级发文 | 通知公告 | 上级发文 | 下载专区 |
| -------- | -------- | -------- | -------- |
| 1798 | 1799 | 2270 | 1797 |
</Route>
## 南京信息工程大学
::: tip 提示

View File

@@ -2161,6 +2161,9 @@ router.get('/coronavirus/dxy', require('./routes/coronavirus/dxy'));
router.get('/coronavirus/scmp', require('./routes/coronavirus/scmp'));
router.get('/coronavirus/nhc', require('./routes/coronavirus/nhc'));
// 南京林业大学教务处
router.get('/njfu/jwc/:category?', require('./routes/universities/njfu/jwc'));
// 日本経済新聞
router.get('/nikkei/index', require('./routes/nikkei/index'));

View File

@@ -0,0 +1,44 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const url = 'http://jwc.njfu.edu.cn//c';
const map = {
1798: '校级发文',
1799: '通知公告',
2270: '上级发文',
1797: '下载专区',
};
module.exports = async (ctx) => {
const category = map.hasOwnProperty(ctx.params.category) ? ctx.params.category : 1799;
const response = await got({
method: 'get',
url: url + category + '/index.html',
});
const $ = cheerio.load(response.data);
const list = $('.List_R4');
ctx.state.data = {
title: '南京林业大学教务处-' + map[category],
link: url + category + '/index.html',
description: '南京林业大学教务处-' + map[category] + 'Rss源',
item: list
.map((index, item) => ({
title: $(item)
.find('a')
.attr('title'),
description: $(item)
.find('a')
.attr('title'),
pubDate: $(item)
.find('.List_R4_R')
.text()
.replace(/\[|]/g, ''),
link: $(item)
.find('a')
.attr('href'),
}))
.get(),
};
};