fix(route): fzu 适配新版教务处网站 (#8150)
This commit is contained in:
parent
441417507f
commit
52f18fc74b
|
|
@ -703,6 +703,14 @@ xskb1 对应 <http://www.auto.uestc.edu.cn/index/xskb1.htm>
|
|||
| -------- | -------- |
|
||||
| jxtz | zjjz |
|
||||
|
||||
### 教务处通知(无文章内容)
|
||||
|
||||
<Route author="Lao-Liu233" example="/fzu_min/jxtz" path="/fzu_min/:type" :paramsDesc="['分类见下表']"/>
|
||||
|
||||
| 教学通知 | 专家讲座 |
|
||||
| -------- | -------- |
|
||||
| jxtz | zjjz |
|
||||
|
||||
## 复旦大学继续教育学院
|
||||
|
||||
### 成人夜大通知公告
|
||||
|
|
|
|||
|
|
@ -910,6 +910,7 @@ router.get('/lyu/news/:type', lazyloadRouteHandler('./routes/universities/lyu/ne
|
|||
|
||||
// 福州大学
|
||||
router.get('/fzu/:type', lazyloadRouteHandler('./routes/universities/fzu/news'));
|
||||
router.get('/fzu_min/:type', lazyloadRouteHandler('./routes/universities/fzu/news_min'));
|
||||
|
||||
// 厦门大学
|
||||
router.get('/xmu/aero/:type', lazyloadRouteHandler('./routes/universities/xmu/aero'));
|
||||
|
|
|
|||
|
|
@ -1,14 +1,6 @@
|
|||
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: '专家讲座',
|
||||
|
|
@ -22,17 +14,22 @@ 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]}`,
|
||||
},
|
||||
url: `https://jwch.fzu.edu.cn/${type}.htm`,
|
||||
});
|
||||
const data = response.data.data;
|
||||
const data = response.data; // 获取页面 html 数据
|
||||
|
||||
const urls = new Array();
|
||||
for (let i = 0; i <= 9; i++) {
|
||||
urls[i] = data[i].url;
|
||||
}
|
||||
const $ = cheerio.load(data);
|
||||
const list = $('ul.list-gl'); // <li>s
|
||||
|
||||
const urls = [];
|
||||
|
||||
const url_head = 'https://jwch.fzu.edu.cn/';
|
||||
|
||||
list.find('a').each(function () {
|
||||
const a = $(this);
|
||||
const url_part = a.attr('href');
|
||||
urls.push(url_head + url_part);
|
||||
});
|
||||
|
||||
const items = await Promise.all(
|
||||
urls.map((item) =>
|
||||
|
|
@ -57,7 +54,7 @@ module.exports = async (ctx) => {
|
|||
|
||||
ctx.state.data = {
|
||||
title: `福州大学教务处${title_map[type]}`,
|
||||
link: `http://jwch.fzu.edu.cn/jxtz/`,
|
||||
link: `http://jwch.fzu.edu.cn/${type}`,
|
||||
description: `福州大学教务处${description_map[type]}`,
|
||||
item: items,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
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: `https://jwch.fzu.edu.cn/${type}.htm`,
|
||||
});
|
||||
const data = response.data; // 获取页面 html 数据
|
||||
|
||||
const $ = cheerio.load(data);
|
||||
const list = $('ul.list-gl').find('li'); // <li>s
|
||||
|
||||
const url_head = 'https://jwch.fzu.edu.cn/';
|
||||
|
||||
ctx.state.data = {
|
||||
title: `福州大学教务处${title_map[type]}`,
|
||||
link: `http://jwch.fzu.edu.cn/${type}`,
|
||||
description: `福州大学教务处${description_map[type]}`,
|
||||
item:
|
||||
list &&
|
||||
list
|
||||
.map((index, item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.find('a').attr('title'),
|
||||
discription: item.find('a').attr('title'),
|
||||
link: url_head + item.find('a').attr('href'),
|
||||
pubDate: item.find('span').html(),
|
||||
};
|
||||
})
|
||||
.get(),
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue