feat(route): 福州大学 Routers 添加全文获取 (#7106)

* add 福州大学

添加 route 福州大学-教务通知/专家讲座

* fix: fzu wrong spelling

* fix: FZU add detailed discription

* Revert "fix: FZU add detailed discription"

This reverts commit f2d49b49a9.

* add description to jxtz.js

* merge two routers; add description to zjjz.

* edit the docs; fix some problems.
This commit is contained in:
Lao-Liu233
2021-03-16 17:09:35 -04:00
committed by GitHub
parent cabcc238bd
commit eaf9b4c6a6
5 changed files with 71 additions and 53 deletions
+5 -5
View File
@@ -478,13 +478,13 @@ xskb1 对应 <http://www.auto.uestc.edu.cn/index/xskb1.htm>
## 福州大学
### 教务处教学通知
### 教务处通知
<Route author="Lao-Liu233" example="/fzu/jxtz" path="/fzu/jxtz"/>
<Route author="Lao-Liu233" example="/fzu/jxtz" path="/fzu/:type" :paramsDesc="['分类见下表']"/>
### 教务处专家讲座
<Route author="Lao-Liu233" example="/fzu/zjjz" path="/fzu/zjjz"/>
| 教学通知 | 专家讲座 |
| -------- | -------- |
| jxtz | zjjz |
## 广东工业大学
+1 -2
View File
@@ -905,8 +905,7 @@ router.get('/usst/jwc', require('./routes/universities/usst/jwc'));
router.get('/lyu/news/:type', require('./routes/universities/lyu/news/index'));
// 福州大学
router.get('/fzu/jxtz', require('./routes/universities/fzu/jxtz'));
router.get('/fzu/zjjz', require('./routes/universities/fzu/zjjz'));
router.get('/fzu/:type', require('./routes/universities/fzu/news'));
// ifanr
router.get('/ifanr/:channel?', require('./routes/ifanr/index'));
-23
View File
@@ -1,23 +0,0 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: `http://jwch.fzu.edu.cn/plus/json.aspx?jid=J131925584886784703&classid=1804&page=1&column=infoid%2Cclassid%2Ctitle%2Cdefaultpic%2Cintro%2Cadddate%2Curl%2Cclassname`,
headers: {
Referer: `http://jwch.fzu.edu.cn/jxtz/`,
},
});
const data = response.data.data;
ctx.state.data = {
title: `福州大学教务处教学通知`,
link: `http://jwch.fzu.edu.cn/jxtz/`,
description: `福州大学教务处教学通知`,
item: data.map((item) => ({
title: item.title,
description: `${item.title}`,
pubDate: `${item.adddate}`,
link: `${item.url}`,
})),
};
};
+65
View File
@@ -0,0 +1,65 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const url_map = {
jxtz: '1804',
zjjz: '1809',
};
const Referer_map = {
jxtz: '/jxtz/',
zjjz: '/zjjz/',
};
const title_map = {
jxtz: '教学通知',
zjjz: '专家讲座',
};
const description_map = {
jxtz: '教学通知',
zjjz: '嘉锡讲坛/信息素养讲座通知',
};
module.exports = async (ctx) => {
const type = ctx.params.type || '';
const response = await got({
method: 'get',
url: `http://jwch.fzu.edu.cn/plus/json.aspx?jid=J131925584886784703&classid=${url_map[type]}&page=1&column=infoid%2Cclassid%2Ctitle%2Cdefaultpic%2Cintro%2Cadddate%2Curl%2Cclassname`,
headers: {
Referer: `http://jwch.fzu.edu.cn${Referer_map[type]}`,
},
});
const data = response.data.data;
const urls = new Array();
for (let i = 0; i <= 9; i++) {
urls[i] = data[i].url;
}
const items = await Promise.all(
urls.map(
async (item) =>
await ctx.cache.tryGet(item, async () => {
const response = await got({
method: 'get',
url: item,
});
const $ = cheerio.load(response.data);
const title = $('title').html();
const description = $('.articelMain').html();
const pubDate = $('.xl_sj_icon').text().replace('发布时间:', '');
return {
title,
link: item,
description,
pubDate,
};
})
)
);
ctx.state.data = {
title: `福州大学教务处${title_map[type]}`,
link: `http://jwch.fzu.edu.cn/jxtz/`,
description: `福州大学教务处${description_map[type]}`,
item: items,
};
};
-23
View File
@@ -1,23 +0,0 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: `http://jwch.fzu.edu.cn/plus/json.aspx?jid=J131925584886784703&classid=1809&page=1&column=infoid%2Cclassid%2Ctitle%2Cdefaultpic%2Cintro%2Cadddate%2Curl%2Cclassname`,
headers: {
Referer: `http://jwch.fzu.edu.cn/zjjz/`,
},
});
const data = response.data.data;
ctx.state.data = {
title: `福州大学教务处专家讲座`,
link: `http://jwch.fzu.edu.cn/zjjz/`,
description: `福州大学教务处加锡讲坛/信息素养讲座通知`,
item: data.map((item) => ({
title: item.title,
description: `${item.title}`,
pubDate: `${item.adddate}`,
link: `${item.url}`,
})),
};
};