Skip to content

Commit

Permalink
Add some SCNU RSS support (DIYgod#401)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengkx authored and DIYgod committed Aug 1, 2018
1 parent 9776151 commit b8a75ed
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
- Next 主题
- 小米
- 众筹
- 华南师范大学
- 教务处通知
- 图书馆通知
- 计算机学院竞赛通知

</details>

Expand Down
26 changes: 26 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1567,3 +1567,29 @@ id, 专辑 id, 可在对应专辑页面的 URL 中找到
路由: `/mi/crowdfunding`

参数: 无

## 华南师范大学

### 教务处通知

举例: [https://rsshub.app/scnu/jw](https://rsshub.app/scnu/jw)

路由: `/scnu/jw`

参数:无

### 图书馆通知

举例: [https://rsshub.app/scnu/library](https://rsshub.app/scnu/library)

路由: `/scnu/library`

参数:无

### 计算机学院竞赛通知

举例: [https://rsshub.app/scnu/cs/match](https://rsshub.app/scnu/cs/match)

路由: `/scnu/cs/match`

参数:无
5 changes: 5 additions & 0 deletions router.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,4 +360,9 @@ router.get('/hexo/next/:url', require('./routes/hexo/next'));
// 小米
router.get('/mi/crowdfunding', require('./routes/mi/crowdfunding'));

// SCNU
router.get('/scnu/jw', require('./routes/scnu/jw'));
router.get('/scnu/library', require('./routes/scnu/library'));
router.get('/scnu/cs/match', require('./routes/scnu/cs/match'));

module.exports = router;
38 changes: 38 additions & 0 deletions routes/scnu/cs/match.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const axios = require('../../../utils/axios');
const cheerio = require('cheerio');
const config = require('../../../config');

module.exports = async (ctx) => {
const res = await axios({
method: 'get',
url: 'https://cs.scnu.edu.cn/xueshenggongzuo/chengchangfazhan/kejichuangxin/',
header: {
'User-Agent': config.ua,
Referer: 'https://cs.scnu.edu.cn',
},
});
const data = res.data;
const $ = cheerio.load(data);
const list = $('.listshow').find('li');

ctx.state.data = {
title: $('title').text(),
link: 'https://cs.scnu.edu.cn/xueshenggongzuo/chengchangfazhan/kejichuangxin/',
description: '华南师范大学计算机学院 学科竞赛',
item:
list &&
list
.map((index, item) => {
item = $(item);
return {
title: item
.find('a')
.text()
.replace(/\d{4}-\d{2}-\d{2}/, ''),
pubDate: new Date(item.find('.r').text()).toUTCString(),
link: item.find('a').attr('href'),
};
})
.get(),
};
};
37 changes: 37 additions & 0 deletions routes/scnu/jw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const axios = require('../../utils/axios');
const cheerio = require('cheerio');
const config = require('../../config');

module.exports = async (ctx) => {
const res = await axios({
method: 'get',
url: 'https://jw.scnu.edu.cn/ann/index.html',
header: {
'User-Agent': config.ua,
Referer: 'https://jw.scnu.edu.cn',
},
});
const data = res.data;
const $ = cheerio.load(data);
const list = $('.notice_01').find('li');

ctx.state.data = {
title: $('title')
.first()
.text(),
link: 'https://jw.scnu.edu.cn/ann/index.html',
description: '华南师范大学教务处 - 通知公告',
item:
list &&
list
.map((index, item) => {
item = $(item);
return {
title: item.find('a').text(),
pubDate: new Date(item.find('.time').text()).toUTCString(),
link: item.find('a').attr('href'),
};
})
.get(),
};
};
35 changes: 35 additions & 0 deletions routes/scnu/library.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const axios = require('../../utils/axios');
const cheerio = require('cheerio');
const config = require('../../config');

module.exports = async (ctx) => {
const res = await axios({
method: 'get',
url: 'https://lib.scnu.edu.cn/news/zuixingonggao',
header: {
'User-Agent': config.ua,
Referer: 'https://lib.scnu.edu.cn',
},
});
const data = res.data;
const $ = cheerio.load(data);
const list = $('.article-list').find('li');

ctx.state.data = {
title: $('title').text(),
link: 'https://lib.scnu.edu.cn/news/zuixingonggao',
description: '华南师范大学图书馆 - 通知公告',
item:
list &&
list
.map((index, item) => {
item = $(item);
return {
title: item.find('a').text(),
pubDate: new Date(item.find('.clock').text()).toUTCString(),
link: item.find('a').attr('href'),
};
})
.get(),
};
};

0 comments on commit b8a75ed

Please sign in to comment.