fix failed route: universities/hust/

rel: issues/1680
1. fix /hust/auto/notice/:type? & /hust/auto/new
2. add /hust/aia/notice/:type? & /hust/aia/new
This commit is contained in:
Ray Wong
2019-03-05 12:06:44 +08:00
parent 7a89b9de5f
commit 1f59667cb0
6 changed files with 85 additions and 10 deletions
Regular → Executable
+2 -2
View File
@@ -1827,7 +1827,7 @@ https://rsshub.app/**nuist**/`bulletin` 或 https://rsshub.app/**nuist**/`bullet
### 华中科技大学
<route name="自动化学院通知" author="jinxiapu" example="/hust/auto/notice/0" path="/universities/hust/auto/notice/:type?" :paramsDesc="['分区 type, 默认为最新通知 可在网页 HTML中找到']">
<route name="人工智能和自动化学院通知" author="RayHY" example="/hust/aia/notice/0" path="/universities/hust/aia/notice/:type?" :paramsDesc="['分区 type, 默认为最新通知 可在网页 HTML中找到']">
| 最新 | 行政 | 人事 | 科研 | 讲座 | 本科生 | 研究生 | 学工 |
| ---- | ---- | ---- | ---- | ---- | ------ | ------ | ---- |
@@ -1835,7 +1835,7 @@ https://rsshub.app/**nuist**/`bulletin` 或 https://rsshub.app/**nuist**/`bullet
</route>
<route name="自动化学院新闻" author="jinxiapu" example="/hust/auto/news" path="/universities/hust/auto/news" />
<route name="人工智能和自动化学院新闻" author="RayHY" example="/hust/aia/news" path="/universities/hust/aia/news" />
### 山东大学
Regular → Executable
+2
View File
@@ -667,6 +667,8 @@ router.get('/kmust/job/jobfairs', require('./routes/universities/kmust/job/jobfa
// 华中科技大学
router.get('/hust/auto/notice/:type?', require('./routes/universities/hust/auto/notice'));
router.get('/hust/auto/news/', require('./routes/universities/hust/auto/news'));
router.get('/hust/aia/news/', require('./routes/universities/hust/aia/news'));
router.get('/hust/aia/notice/:type?', require('./routes/universities/hust/aia/notice'));
// 山东大学
router.get('/sdu/grad/academic', require('./routes/universities/sdu/grad/academic'));
+34
View File
@@ -0,0 +1,34 @@
const axios = require('../../../../utils/axios');
const cheerio = require('cheerio');
const url = require('url').resolve;
module.exports = async (ctx) => {
const link = 'http://aia.hust.edu.cn/yxxw.htm';
const response = await axios.get(link);
const $ = cheerio.load(response.data);
const list = $('.N02_list li dl');
ctx.state.data = {
title: '华科人工智能和自动化学院新闻',
link: link,
description: '华科人工智能和自动化学院新闻',
item:
list &&
list
.map((index, item) => {
item = $(item);
const day = item.find('.N02_list_Icon i').text();
item.find('.N02_list_Icon')
.find('i')
.remove();
const year_month = item.find('.N02_list_Icon').text();
return {
title: item.find('h4 a').text(),
description: item.find('dd p').text() || '华科人工智能和自动化学院新闻',
pubDate: new Date(year_month + ' ' + day).toUTCString(),
link: url(link, item.find('h4 a').attr('href')),
};
})
.get(),
};
};
+39
View File
@@ -0,0 +1,39 @@
const axios = require('../../../../utils/axios');
const cheerio = require('cheerio');
const url = require('url').resolve;
const typelist = ['最新', '行政', '人事', '科研', '讲座', '本科生', '研究生', '学工'];
module.exports = async (ctx) => {
const type = parseInt(ctx.params.type) || 0;
const link = 'http://aia.hust.edu.cn/';
const response = await axios.get(link);
const $ = cheerio.load(response.data);
const list = $('.m_content .m_con')
.eq(type)
.find('.N02_list_dl');
ctx.state.data = {
title: `华科人工智能和自动化学院${typelist[type]}通知`,
link: link,
description: `华科人工智能和自动化学院${typelist[type]}通知`,
item:
list &&
list
.map((index, item) => {
item = $(item);
const day = item.find('.N02_list_Icon i').text();
item.find('.N02_list_Icon')
.find('i')
.remove();
const year_month = item.find('.N02_list_Icon').text();
return {
title: item.find('h4 a').text(),
description: item.find('dd p').text() || `华科人工智能和自动化学院${typelist[type]}通知`,
pubDate: new Date(year_month + ' ' + day).toUTCString(),
link: url(link, item.find('h4 a').attr('href')),
};
})
.get(),
};
};
+4 -4
View File
@@ -3,15 +3,15 @@ const cheerio = require('cheerio');
const url = require('url').resolve;
module.exports = async (ctx) => {
const link = 'http://auto.hust.edu.cn/yxxw.htm';
const link = 'http://aia.hust.edu.cn/yxxw.htm';
const response = await axios.get(link);
const $ = cheerio.load(response.data);
const list = $('.N02_list li dl');
ctx.state.data = {
title: '华科自动化学院新闻',
title: '华科人工智能和自动化学院新闻',
link: link,
description: '华科自动化学院新闻',
description: '华科人工智能和自动化学院新闻',
item:
list &&
list
@@ -24,7 +24,7 @@ module.exports = async (ctx) => {
const year_month = item.find('.N02_list_Icon').text();
return {
title: item.find('h4 a').text(),
description: item.find('dd p').text() || '华科自动化学院新闻',
description: item.find('dd p').text() || '华科人工智能和自动化学院新闻',
pubDate: new Date(year_month + ' ' + day).toUTCString(),
link: url(link, item.find('h4 a').attr('href')),
};
+4 -4
View File
@@ -6,7 +6,7 @@ const typelist = ['最新', '行政', '人事', '科研', '讲座', '本科生',
module.exports = async (ctx) => {
const type = parseInt(ctx.params.type) || 0;
const link = 'http://auto.hust.edu.cn/';
const link = 'http://aia.hust.edu.cn/';
const response = await axios.get(link);
const $ = cheerio.load(response.data);
const list = $('.m_content .m_con')
@@ -14,9 +14,9 @@ module.exports = async (ctx) => {
.find('.N02_list_dl');
ctx.state.data = {
title: `华科自动化学院${typelist[type]}通知`,
title: `华科人工智能和自动化学院${typelist[type]}通知`,
link: link,
description: `华科自动化学院${typelist[type]}通知`,
description: `华科人工智能和自动化学院${typelist[type]}通知`,
item:
list &&
list
@@ -29,7 +29,7 @@ module.exports = async (ctx) => {
const year_month = item.find('.N02_list_Icon').text();
return {
title: item.find('h4 a').text(),
description: item.find('dd p').text() || `华科自动化学院${typelist[type]}通知`,
description: item.find('dd p').text() || `华科人工智能和自动化学院${typelist[type]}通知`,
pubDate: new Date(year_month + ' ' + day).toUTCString(),
link: url(link, item.find('h4 a').attr('href')),
};