添加常州大学教务处等网站通知 (#706)

This commit is contained in:
Richard Chien 2018-09-16 16:44:45 +08:00 committed by DIYgod
parent 818e0cd077
commit 85a2a5ae9b
4 changed files with 104 additions and 0 deletions

View File

@ -2188,6 +2188,36 @@ category 列表:
| --------- |
| news |
### 常州大学
#### 教务处
举例: <https://rsshub.app/cczu/jwc/1425>
路由: `/cczu/jwc/:category?`
参数:
- category, 可选, 默认为 `all`
| 全部 | 通知公告 | 教务新闻 | 各类活动与系列讲座 | 本科教学工程 | 他山之石 | 信息快递 |
| ---- | -------- | -------- | ------------------ | ------------ | -------- | -------- |
| all | 1425 | 1437 | 1485 | 1487 | 1442 | 1445 |
#### 新闻网
举例: <https://rsshub.app/cczu/news/6620>
路由: `/cczu/news/:category?`
参数:
- category, 可选, 默认为 `all`
| 全部 | 常大要闻 | 校园快讯 | 媒体常大 | 时事热点 | 高教动态 | 网上橱窗 | 新媒常大 |
| ---- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |
| all | 6620 | 6621 | 6687 | 6628 | 6629 | 6640 | 6645 |
## 传统媒体
### 央视新闻

View File

@ -523,6 +523,10 @@ router.get('/cuit/cxxww/:type?', require('./routes/universities/cuit/cxxww'));
router.get('/cqust/jw/:type?', require('./routes/universities/cqust/jw'));
router.get('/cqust/lib/:type?', require('./routes/universities/cqust/lib'));
// 常州大学
router.get('/cczu/jwc/:category?', require('./routes/universities/cczu/jwc'));
router.get('/cczu/news/:category?', require('./routes/universities/cczu/news'));
// ifanr
router.get('/ifanr/appso', require('./routes/ifanr/appso'));

View File

@ -0,0 +1,35 @@
const axios = require('../../../utils/axios');
const cheerio = require('cheerio');
const url = require('url');
const baseTitle = '常大教务处';
const baseUrl = 'http://jwc.cczu.edu.cn';
const entryUrlRegex = /^\/(20\d{2})\/(\d{2})(\d{2})\/.*$/;
module.exports = async (ctx) => {
const category = ctx.params.category || 'all';
const pageUrl = baseUrl + (category === 'all' ? '/' : `/${category}/list.htm`);
const response = await axios({
method: 'get',
url: pageUrl,
headers: {
Referer: baseUrl,
},
});
const $ = cheerio.load(response.data);
ctx.state.data = {
link: pageUrl,
title: category === 'all' ? baseTitle : `${baseTitle} ${$('title').text()}`,
item: $('div[id^="wp_news_w"] a')
.filter((_, elem) => elem.attribs.href.match(entryUrlRegex))
.map((_, elem) => ({
link: url.resolve(pageUrl, elem.attribs.href),
title: elem.attribs.title,
pubDate: new Date(elem.attribs.href.replace(entryUrlRegex, '$1-$2-$3')),
}))
.get(),
};
};

View File

@ -0,0 +1,35 @@
const axios = require('../../../utils/axios');
const cheerio = require('cheerio');
const url = require('url');
const baseTitle = '常大新闻网';
const baseUrl = 'http://news.cczu.edu.cn';
const entryUrlRegex = /^\/(20\d{2})\/(\d{2})(\d{2})\/.*$/;
module.exports = async (ctx) => {
const category = ctx.params.category || 'all';
const pageUrl = baseUrl + (category === 'all' ? '/' : `/${category}/list.htm`);
const response = await axios({
method: 'get',
url: pageUrl,
headers: {
Referer: baseUrl,
},
});
const $ = cheerio.load(response.data);
ctx.state.data = {
link: pageUrl,
title: category === 'all' ? baseTitle : `${baseTitle} ${$('title').text()}`,
item: $('div[id^="wp_news_w"] a')
.filter((_, elem) => elem.attribs.href.match(entryUrlRegex))
.map((_, elem) => ({
link: url.resolve(pageUrl, elem.attribs.href),
title: elem.attribs.title,
pubDate: new Date(elem.attribs.href.replace(entryUrlRegex, '$1-$2-$3')),
}))
.get(),
};
};