feat: add pkueecs (#347)

This commit is contained in:
Ir1dXD
2018-07-13 14:53:57 +08:00
committed by DIYgod
parent 1487b50a71
commit 158a31d23c
3 changed files with 61 additions and 0 deletions

View File

@@ -1433,3 +1433,17 @@ id, 专辑 id, 可在对应专辑页面的 URL 中找到
举例: [https://rsshub.app/kejixingqiu/home](https://rsshub.app/kejixingqiu/home) 举例: [https://rsshub.app/kejixingqiu/home](https://rsshub.app/kejixingqiu/home)
路由: `/kejixingqiu/home` 路由: `/kejixingqiu/home`
## 北大信科
### 公告通知
举例: [https://rsshub.app/pku/eecs/0](https://rsshub.app/pku/eecs/0)
路由: `/eecs/:type`
可选参数: type分区 type可在网页 URL 中找到
| 全部 | 学院通知 | 人事通知 | 教务通知 | 学工通知 | 科研通知 | 财务通知 | 工会通知 | 院友通知 |
| ---- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |
| 0 | 1 | 2 | 6 | 8 | 7 | 5 | 3 | 4 |

View File

@@ -325,6 +325,7 @@ router.get('/mihoyo/bh2/:type', require('./routes/mihoyo/bh2'));
// 灵梦御所 // 灵梦御所
router.get('/reimu/category/:category', require('./routes/reimu/category')); router.get('/reimu/category/:category', require('./routes/reimu/category'));
router.get('/reimu/tag/:tag', require('./routes/reimu/tag')); router.get('/reimu/tag/:tag', require('./routes/reimu/tag'));
// 央视新闻 // 央视新闻
router.get('/cctv/:category', require('./routes/cctv/category')); router.get('/cctv/:category', require('./routes/cctv/category'));
@@ -334,4 +335,7 @@ router.get('/t66y/:id', require('./routes/t66y/index'));
// 科技星球 // 科技星球
router.get('/kejixingqiu/home', require('./routes/kejixingqiu/home')); router.get('/kejixingqiu/home', require('./routes/kejixingqiu/home'));
// PKUEECS
router.get('/pku/eecs/:type?', require('./routes/pku/eecs'));
module.exports = router; module.exports = router;

43
routes/pku/eecs.js Normal file
View File

@@ -0,0 +1,43 @@
const axios = require('../../utils/axios');
const cheerio = require('cheerio');
const config = require('../../config');
module.exports = async (ctx) => {
const host = 'http://eecs.pku.edu.cn/';
let type = ctx.params && ctx.params.type;
if (type === undefined) {
type = '0';
}
const response = await axios({
method: 'get',
url: host + 'Survey/Notice/?Mtitle=' + type,
headers: {
'User-Agent': config.ua,
Referer: host,
},
});
const $ = cheerio.load(response.data);
const text = $('.hvr-shutter-out-vertical');
ctx.state.data = {
title: '',
link: host + 'Survey/Notice/?Mtitle=' + type,
description: '北大信科 公告通知',
item:
text &&
text
.map((index, item) => {
item = $(item);
return {
title: item.find('p').text(),
link: host + item.attr('href'),
description: item.find('p').text(),
pubDate: item.find('em').text(),
};
})
.get(),
};
};