mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 23:00:48 +08:00
reorganize sjtu-seiee section (#1981)
This commit is contained in:
@@ -139,15 +139,13 @@
|
|||||||
|
|
||||||
<Route name="电子信息与电气工程学院学术动态" author="HenryQW" example="/sjtu/seiee/academic" path="/universities/sjtu/seiee/academic"/>
|
<Route name="电子信息与电气工程学院学术动态" author="HenryQW" example="/sjtu/seiee/academic" path="/universities/sjtu/seiee/academic"/>
|
||||||
|
|
||||||
<Route name="电子信息与电气工程学院本科教务办 -- 分专业" author="SkyZH" example="/sjtu/seiee/bjwb/major_select" path="/universities/sjtu/seiee/bjwb/major_select"/>
|
<Route name="电子信息与电气工程学院本科教务办" author="Polynomia" example="/sjtu/seiee/xsb/news" path="/universities/sjtu/seiee/bjwb/:type" :paramsDesc="['无默认选项']">
|
||||||
|
|
||||||
<Route name="电子信息与电气工程学院本科教务办 -- 转专业" author="SkyZH" example="/sjtu/seiee/bjwb/major_transfer" path="/universities/sjtu/seiee/bjwb/major_transfer"/>
|
| 分专业 | 转专业 | 直升研究生 | 交换交流 | 国际办学 |
|
||||||
|
| ------------ | -------------- | ------------ | -------- | ------------- |
|
||||||
|
| major_select | major_transfer | postgraduate | abroad | international |
|
||||||
|
|
||||||
<Route name="电子信息与电气工程学院本科教务办 -- 交换交流" author="SkyZH" example="/sjtu/seiee/bjwb/abroad" path="/universities/sjtu/seiee/bjwb/abroad"/>
|
</Route>
|
||||||
|
|
||||||
<Route name="电子信息与电气工程学院本科教务办 -- 直升研究生" author="SkyZH" example="/sjtu/seiee/bjwb/postgraduate" path="/universities/sjtu/seiee/bjwb/postgraduate"/>
|
|
||||||
|
|
||||||
<Route name="电子信息与电气工程学院本科教务办 -- 国际办学" author="SkyZH" example="/sjtu/seiee/bjwb/international" path="/universities/sjtu/seiee/bjwb/international"/>
|
|
||||||
|
|
||||||
<Route name="研究生通知公告" author="mzr1996" example="/sjtu/gs/tzgg/pyxx" path="/universities/sjtu/gs/tzgg/:type?" :paramsDesc="['默认列举所有通知公告']">
|
<Route name="研究生通知公告" author="mzr1996" example="/sjtu/gs/tzgg/pyxx" path="/universities/sjtu/gs/tzgg/:type?" :paramsDesc="['默认列举所有通知公告']">
|
||||||
|
|
||||||
|
|||||||
@@ -607,11 +607,7 @@ router.get('/shanghaitech/sist/activity', require('./routes/universities/shangha
|
|||||||
|
|
||||||
// 上海交通大学
|
// 上海交通大学
|
||||||
router.get('/sjtu/seiee/academic', require('./routes/universities/sjtu/seiee/academic'));
|
router.get('/sjtu/seiee/academic', require('./routes/universities/sjtu/seiee/academic'));
|
||||||
router.get('/sjtu/seiee/bjwb/major_select', require('./routes/universities/sjtu/seiee/bjwb/major_select'));
|
router.get('/sjtu/seiee/bjwb/:type', require('./routes/universities/sjtu/seiee/bjwb'));
|
||||||
router.get('/sjtu/seiee/bjwb/major_transfer', require('./routes/universities/sjtu/seiee/bjwb/major_transfer'));
|
|
||||||
router.get('/sjtu/seiee/bjwb/postgraduate', require('./routes/universities/sjtu/seiee/bjwb/postgraduate'));
|
|
||||||
router.get('/sjtu/seiee/bjwb/abroad', require('./routes/universities/sjtu/seiee/bjwb/abroad'));
|
|
||||||
router.get('/sjtu/seiee/bjwb/international', require('./routes/universities/sjtu/seiee/bjwb/international'));
|
|
||||||
router.get('/sjtu/seiee/xsb/:type?', require('./routes/universities/sjtu/seiee/xsb'));
|
router.get('/sjtu/seiee/xsb/:type?', require('./routes/universities/sjtu/seiee/xsb'));
|
||||||
|
|
||||||
router.get('/sjtu/gs/tzgg/:type?', require('./routes/universities/sjtu/gs/tzgg'));
|
router.get('/sjtu/gs/tzgg/:type?', require('./routes/universities/sjtu/gs/tzgg'));
|
||||||
|
|||||||
@@ -1,52 +1,26 @@
|
|||||||
const axios = require('../../../../utils/axios');
|
const workerFactory = require('./utils');
|
||||||
const cheerio = require('cheerio');
|
|
||||||
const url = require('url');
|
|
||||||
|
|
||||||
const host = 'http://www.seiee.sjtu.edu.cn/';
|
module.exports = workerFactory(
|
||||||
|
() => ({
|
||||||
module.exports = async (ctx) => {
|
title: '上海交通大学电子信息与电气工程学院本科教务办 -- 学术动态',
|
||||||
const link = url.resolve(host, 'seiee/list/683-1-20.htm');
|
local: `seiee/list/683-1-20.htm`,
|
||||||
const response = await axios.get(link);
|
author: '上海交通大学电子信息与电气工程学院本科教务办',
|
||||||
|
}),
|
||||||
const $ = cheerio.load(response.data);
|
($) =>
|
||||||
|
$('.list_box_5 li')
|
||||||
const list = $('.list_style_1 li a')
|
.slice(0, 10)
|
||||||
.slice(0, 10)
|
.map((i, e) => ({
|
||||||
.map((i, e) => $(e).attr('href'))
|
date: $(e)
|
||||||
.get();
|
.children('span')
|
||||||
|
.text()
|
||||||
const out = await Promise.all(
|
.slice(1, -1),
|
||||||
list.map(async (itemUrl) => {
|
title: $(e)
|
||||||
itemUrl = url.resolve(host, itemUrl);
|
.children('a')
|
||||||
const cache = await ctx.cache.get(itemUrl);
|
.text()
|
||||||
if (cache) {
|
.slice(2),
|
||||||
return Promise.resolve(JSON.parse(cache));
|
link: $(e)
|
||||||
}
|
.children('a')
|
||||||
|
.attr('href'),
|
||||||
const response = await axios.get(itemUrl);
|
}))
|
||||||
const $ = cheerio.load(response.data);
|
.get()
|
||||||
|
);
|
||||||
const single = {
|
|
||||||
title: $('h2.title_3').text(),
|
|
||||||
link: itemUrl,
|
|
||||||
author: '上海交通大学电子信息与电气工程学院',
|
|
||||||
description: $('.c_1.article_content')
|
|
||||||
.html()
|
|
||||||
.replace(/src="\//g, `src="${url.resolve(host, '.')}`),
|
|
||||||
pubDate: new Date(
|
|
||||||
$('.date_1 span:first-of-type')
|
|
||||||
.text()
|
|
||||||
.trim()
|
|
||||||
).toUTCString(),
|
|
||||||
};
|
|
||||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
|
||||||
return Promise.resolve(single);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
ctx.state.data = {
|
|
||||||
title: '上海交通大学电子信息与电气工程学院 -- 学术动态',
|
|
||||||
link,
|
|
||||||
item: out,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|||||||
53
lib/routes/universities/sjtu/seiee/bjwb.js
Normal file
53
lib/routes/universities/sjtu/seiee/bjwb.js
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
const workerFactory = require('./utils');
|
||||||
|
|
||||||
|
module.exports = workerFactory(
|
||||||
|
(ctx) => {
|
||||||
|
const config = {
|
||||||
|
abroad: {
|
||||||
|
link: `bkjwb/list/1507-1-20.htm`,
|
||||||
|
title: '交换交流',
|
||||||
|
},
|
||||||
|
international: {
|
||||||
|
link: `bkjwb/list/2281-1-20.htm`,
|
||||||
|
title: '国际办学通知',
|
||||||
|
},
|
||||||
|
major_select: {
|
||||||
|
link: `bkjwb/list/1503-1-20.htm`,
|
||||||
|
title: '分专业',
|
||||||
|
},
|
||||||
|
major_transfer: {
|
||||||
|
link: `bkjwb/list/1505-1-20.htm`,
|
||||||
|
title: '转专业',
|
||||||
|
},
|
||||||
|
postgraduate: {
|
||||||
|
link: `bkjwb/list/1506-1-20.htm`,
|
||||||
|
title: '直升研究生',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const type = ctx.params.type;
|
||||||
|
|
||||||
|
return {
|
||||||
|
title: '上海交通大学电子信息与电气工程学院学生办 -- ' + config[type].title,
|
||||||
|
local: config[type].link,
|
||||||
|
author: '上海交通大学电子信息与电气工程学院本科教务办',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
($) =>
|
||||||
|
$('.list_box_5 li')
|
||||||
|
.slice(0, 10)
|
||||||
|
.map((i, e) => ({
|
||||||
|
date: $(e)
|
||||||
|
.children('span')
|
||||||
|
.text()
|
||||||
|
.slice(1, -1),
|
||||||
|
title: $(e)
|
||||||
|
.children('a')
|
||||||
|
.text()
|
||||||
|
.slice(2),
|
||||||
|
link: $(e)
|
||||||
|
.children('a')
|
||||||
|
.attr('href'),
|
||||||
|
}))
|
||||||
|
.get()
|
||||||
|
);
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
const axios = require('../../../../../utils/axios');
|
|
||||||
const cheerio = require('cheerio');
|
|
||||||
const url = require('url');
|
|
||||||
|
|
||||||
const host = 'http://bjwb.seiee.sjtu.edu.cn';
|
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
|
||||||
const link = url.resolve(host, `bkjwb/list/1507-1-20.htm`);
|
|
||||||
const response = await axios.get(link);
|
|
||||||
|
|
||||||
const $ = cheerio.load(response.data);
|
|
||||||
|
|
||||||
const list = $('.list_box_5 li')
|
|
||||||
.slice(0, 10)
|
|
||||||
.map((i, e) => ({
|
|
||||||
date: $(e)
|
|
||||||
.children('span')
|
|
||||||
.text()
|
|
||||||
.slice(1, -1),
|
|
||||||
title: $(e)
|
|
||||||
.children('a')
|
|
||||||
.text()
|
|
||||||
.slice(2),
|
|
||||||
link: $(e)
|
|
||||||
.children('a')
|
|
||||||
.attr('href'),
|
|
||||||
}))
|
|
||||||
.get();
|
|
||||||
|
|
||||||
const out = await Promise.all(
|
|
||||||
list.map(async (item) => {
|
|
||||||
const itemUrl = url.resolve(host, item.link);
|
|
||||||
const cache = await ctx.cache.get(itemUrl);
|
|
||||||
if (cache) {
|
|
||||||
return Promise.resolve(JSON.parse(cache));
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await axios.get(itemUrl);
|
|
||||||
const $ = cheerio.load(response.data);
|
|
||||||
|
|
||||||
const single = {
|
|
||||||
title: item.title,
|
|
||||||
link: itemUrl,
|
|
||||||
author: '上海交通大学电子信息与电气工程学院本科教务办',
|
|
||||||
description: $('.article_content').text(),
|
|
||||||
pubDate: new Date(item.date).toUTCString(),
|
|
||||||
};
|
|
||||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
|
||||||
return Promise.resolve(single);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
ctx.state.data = {
|
|
||||||
title: '上海交通大学电子信息与电气工程学院本科教务办 -- 交换交流',
|
|
||||||
link,
|
|
||||||
item: out,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
const axios = require('../../../../../utils/axios');
|
|
||||||
const cheerio = require('cheerio');
|
|
||||||
const url = require('url');
|
|
||||||
|
|
||||||
const host = 'http://bjwb.seiee.sjtu.edu.cn';
|
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
|
||||||
const link = url.resolve(host, `bkjwb/list/2281-1-20.htm`);
|
|
||||||
const response = await axios.get(link);
|
|
||||||
|
|
||||||
const $ = cheerio.load(response.data);
|
|
||||||
|
|
||||||
const list = $('.list_box_5 li')
|
|
||||||
.slice(0, 10)
|
|
||||||
.map((i, e) => ({
|
|
||||||
date: $(e)
|
|
||||||
.children('span')
|
|
||||||
.text()
|
|
||||||
.slice(1, -1),
|
|
||||||
title: $(e)
|
|
||||||
.children('a')
|
|
||||||
.text()
|
|
||||||
.slice(2),
|
|
||||||
link: $(e)
|
|
||||||
.children('a')
|
|
||||||
.attr('href'),
|
|
||||||
}))
|
|
||||||
.get();
|
|
||||||
|
|
||||||
const out = await Promise.all(
|
|
||||||
list.map(async (item) => {
|
|
||||||
const itemUrl = url.resolve(host, item.link);
|
|
||||||
const cache = await ctx.cache.get(itemUrl);
|
|
||||||
if (cache) {
|
|
||||||
return Promise.resolve(JSON.parse(cache));
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await axios.get(itemUrl);
|
|
||||||
const $ = cheerio.load(response.data);
|
|
||||||
|
|
||||||
const single = {
|
|
||||||
title: item.title,
|
|
||||||
link: itemUrl,
|
|
||||||
author: '上海交通大学电子信息与电气工程学院本科教务办',
|
|
||||||
description: $('.article_content').text(),
|
|
||||||
pubDate: new Date(item.date).toUTCString(),
|
|
||||||
};
|
|
||||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
|
||||||
return Promise.resolve(single);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
ctx.state.data = {
|
|
||||||
title: '上海交通大学电子信息与电气工程学院本科教务办 -- 国际办学通知',
|
|
||||||
link,
|
|
||||||
item: out,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
const axios = require('../../../../../utils/axios');
|
|
||||||
const cheerio = require('cheerio');
|
|
||||||
const url = require('url');
|
|
||||||
|
|
||||||
const host = 'http://bjwb.seiee.sjtu.edu.cn';
|
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
|
||||||
const link = url.resolve(host, 'bkjwb/list/1503-1-20.htm');
|
|
||||||
const response = await axios.get(link);
|
|
||||||
|
|
||||||
const $ = cheerio.load(response.data);
|
|
||||||
|
|
||||||
const list = $('.list_box_5 li')
|
|
||||||
.slice(0, 10)
|
|
||||||
.map((i, e) => ({
|
|
||||||
date: $(e)
|
|
||||||
.children('span')
|
|
||||||
.text()
|
|
||||||
.slice(1, -1),
|
|
||||||
title: $(e)
|
|
||||||
.children('a')
|
|
||||||
.text()
|
|
||||||
.slice(2),
|
|
||||||
link: $(e)
|
|
||||||
.children('a')
|
|
||||||
.attr('href'),
|
|
||||||
}))
|
|
||||||
.get();
|
|
||||||
|
|
||||||
const out = await Promise.all(
|
|
||||||
list.map(async (item) => {
|
|
||||||
const itemUrl = url.resolve(host, item.link);
|
|
||||||
const cache = await ctx.cache.get(itemUrl);
|
|
||||||
if (cache) {
|
|
||||||
return Promise.resolve(JSON.parse(cache));
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await axios.get(itemUrl);
|
|
||||||
const $ = cheerio.load(response.data);
|
|
||||||
|
|
||||||
const single = {
|
|
||||||
title: item.title,
|
|
||||||
link: itemUrl,
|
|
||||||
author: '上海交通大学电子信息与电气工程学院本科教务办',
|
|
||||||
description: $('.article_content').text(),
|
|
||||||
pubDate: new Date(item.date).toUTCString(),
|
|
||||||
};
|
|
||||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
|
||||||
return Promise.resolve(single);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
ctx.state.data = {
|
|
||||||
title: '上海交通大学电子信息与电气工程学院本科教务办 -- 分专业',
|
|
||||||
link,
|
|
||||||
item: out,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
const axios = require('../../../../../utils/axios');
|
|
||||||
const cheerio = require('cheerio');
|
|
||||||
const url = require('url');
|
|
||||||
|
|
||||||
const host = 'http://bjwb.seiee.sjtu.edu.cn';
|
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
|
||||||
const link = url.resolve(host, 'bkjwb/list/1505-1-20.htm');
|
|
||||||
const response = await axios.get(link);
|
|
||||||
|
|
||||||
const $ = cheerio.load(response.data);
|
|
||||||
|
|
||||||
const list = $('.list_box_5 li')
|
|
||||||
.slice(0, 10)
|
|
||||||
.map((i, e) => ({
|
|
||||||
date: $(e)
|
|
||||||
.children('span')
|
|
||||||
.text()
|
|
||||||
.slice(1, -1),
|
|
||||||
title: $(e)
|
|
||||||
.children('a')
|
|
||||||
.text()
|
|
||||||
.slice(2),
|
|
||||||
link: $(e)
|
|
||||||
.children('a')
|
|
||||||
.attr('href'),
|
|
||||||
}))
|
|
||||||
.get();
|
|
||||||
|
|
||||||
const out = await Promise.all(
|
|
||||||
list.map(async (item) => {
|
|
||||||
const itemUrl = url.resolve(host, item.link);
|
|
||||||
const cache = await ctx.cache.get(itemUrl);
|
|
||||||
if (cache) {
|
|
||||||
return Promise.resolve(JSON.parse(cache));
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await axios.get(itemUrl);
|
|
||||||
const $ = cheerio.load(response.data);
|
|
||||||
|
|
||||||
const single = {
|
|
||||||
title: item.title,
|
|
||||||
link: itemUrl,
|
|
||||||
author: '上海交通大学电子信息与电气工程学院本科教务办',
|
|
||||||
description: $('.article_content').text(),
|
|
||||||
pubDate: new Date(item.date).toUTCString(),
|
|
||||||
};
|
|
||||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
|
||||||
return Promise.resolve(single);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
ctx.state.data = {
|
|
||||||
title: '上海交通大学电子信息与电气工程学院本科教务办 -- 转专业',
|
|
||||||
link,
|
|
||||||
item: out,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
const axios = require('../../../../../utils/axios');
|
|
||||||
const cheerio = require('cheerio');
|
|
||||||
const url = require('url');
|
|
||||||
|
|
||||||
const host = 'http://bjwb.seiee.sjtu.edu.cn';
|
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
|
||||||
const link = url.resolve(host, 'bkjwb/list/1506-1-20.htm');
|
|
||||||
const response = await axios.get(link);
|
|
||||||
|
|
||||||
const $ = cheerio.load(response.data);
|
|
||||||
|
|
||||||
const list = $('.list_box_5 li')
|
|
||||||
.slice(0, 10)
|
|
||||||
.map((i, e) => ({
|
|
||||||
date: $(e)
|
|
||||||
.children('span')
|
|
||||||
.text()
|
|
||||||
.slice(1, -1),
|
|
||||||
title: $(e)
|
|
||||||
.children('a')
|
|
||||||
.text()
|
|
||||||
.slice(2),
|
|
||||||
link: $(e)
|
|
||||||
.children('a')
|
|
||||||
.attr('href'),
|
|
||||||
}))
|
|
||||||
.get();
|
|
||||||
|
|
||||||
const out = await Promise.all(
|
|
||||||
list.map(async (item) => {
|
|
||||||
const itemUrl = url.resolve(host, item.link);
|
|
||||||
const cache = await ctx.cache.get(itemUrl);
|
|
||||||
if (cache) {
|
|
||||||
return Promise.resolve(JSON.parse(cache));
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await axios.get(itemUrl);
|
|
||||||
const $ = cheerio.load(response.data);
|
|
||||||
|
|
||||||
const single = {
|
|
||||||
title: item.title,
|
|
||||||
link: itemUrl,
|
|
||||||
author: '上海交通大学电子信息与电气工程学院本科教务办',
|
|
||||||
description: $('.article_content').text(),
|
|
||||||
pubDate: new Date(item.date).toUTCString(),
|
|
||||||
};
|
|
||||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
|
||||||
return Promise.resolve(single);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
ctx.state.data = {
|
|
||||||
title: '上海交通大学电子信息与电气工程学院本科教务办 -- 直升研究生',
|
|
||||||
link,
|
|
||||||
item: out,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
45
lib/routes/universities/sjtu/seiee/utils.js
Normal file
45
lib/routes/universities/sjtu/seiee/utils.js
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
const axios = require('../../../../utils/axios');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const url = require('url');
|
||||||
|
|
||||||
|
const host = 'http://bjwb.seiee.sjtu.edu.cn';
|
||||||
|
|
||||||
|
module.exports = function(meta, extract) {
|
||||||
|
return async (ctx) => {
|
||||||
|
const { title, local, author } = meta(ctx);
|
||||||
|
|
||||||
|
const link = url.resolve(host, local);
|
||||||
|
const response = await axios.get(link);
|
||||||
|
|
||||||
|
const list = extract(cheerio.load(response.data));
|
||||||
|
|
||||||
|
const out = await Promise.all(
|
||||||
|
list.map(async (item) => {
|
||||||
|
const itemUrl = url.resolve(host, item.link);
|
||||||
|
const cache = await ctx.cache.get(itemUrl);
|
||||||
|
if (cache) {
|
||||||
|
return Promise.resolve(JSON.parse(cache));
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await axios.get(itemUrl);
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
|
||||||
|
const single = {
|
||||||
|
title: item.title,
|
||||||
|
link: itemUrl,
|
||||||
|
author,
|
||||||
|
description: $('.article_content').text(),
|
||||||
|
pubDate: new Date(item.date).toUTCString(),
|
||||||
|
};
|
||||||
|
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||||
|
return Promise.resolve(single);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title,
|
||||||
|
link,
|
||||||
|
item: out,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -1,87 +1,57 @@
|
|||||||
const axios = require('../../../../utils/axios');
|
const workerFactory = require('./utils');
|
||||||
const cheerio = require('cheerio');
|
|
||||||
const url = require('url');
|
|
||||||
|
|
||||||
const host = 'http://xsb.seiee.sjtu.edu.cn';
|
module.exports = workerFactory(
|
||||||
const config = {
|
(ctx) => {
|
||||||
news: {
|
const config = {
|
||||||
link: `xsb/list/2938-1-20.htm`,
|
news: {
|
||||||
title: '新闻发布',
|
link: 'xsb/list/2938-1-20.htm',
|
||||||
},
|
title: '新闻发布',
|
||||||
scholarship: {
|
},
|
||||||
link: `xsb/list/611-1-20.htm`,
|
scholarship: {
|
||||||
title: '奖学金',
|
link: 'xsb/list/611-1-20.htm',
|
||||||
},
|
title: '奖学金',
|
||||||
activity: {
|
},
|
||||||
link: `xsb/list/2676-1-20.htm`,
|
activity: {
|
||||||
title: '党团活动',
|
link: 'xsb/list/2676-1-20.htm',
|
||||||
},
|
title: '党团活动',
|
||||||
lecture: {
|
},
|
||||||
link: `xsb/list/1981-1-20.htm`,
|
lecture: {
|
||||||
title: '讲座活动',
|
link: 'xsb/list/1981-1-20.htm',
|
||||||
},
|
title: '讲座活动',
|
||||||
all: {
|
},
|
||||||
link: `xsb/list/705-1-20.htm`,
|
all: {
|
||||||
title: '信息通告',
|
link: 'xsb/list/705-1-20.htm',
|
||||||
},
|
title: '信息通告',
|
||||||
financialAid: {
|
},
|
||||||
link: `xsb/list/1001-1-20.htm`,
|
financialAid: {
|
||||||
title: '助学金',
|
link: 'xsb/list/1001-1-20.htm',
|
||||||
},
|
title: '助学金',
|
||||||
};
|
},
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
const type = ctx.params.type || 'all';
|
||||||
let type = ctx.params.type;
|
|
||||||
type = type ? type : 'all';
|
|
||||||
const link = url.resolve(host, config[type].link);
|
|
||||||
const response = await axios.get(link);
|
|
||||||
|
|
||||||
const $ = cheerio.load(response.data);
|
return {
|
||||||
|
title: '上海交通大学电子信息与电气工程学院学生办 -- ' + config[type].title,
|
||||||
const list = $('.list_box_5_2 li')
|
local: config[type].link,
|
||||||
.slice(0, 10)
|
author: '上海交通大学电子信息与电气工程学院学生工作办公室',
|
||||||
.map((i, e) => ({
|
};
|
||||||
date: $(e)
|
},
|
||||||
.children('span')
|
($) =>
|
||||||
.text()
|
$('.list_box_5_2 li')
|
||||||
.slice(1, -1),
|
.slice(0, 10)
|
||||||
title: $(e)
|
.map((i, e) => ({
|
||||||
.children('a')
|
date: $(e)
|
||||||
.text()
|
.children('span')
|
||||||
.slice(1),
|
|
||||||
link: $(e)
|
|
||||||
.children('a')
|
|
||||||
.attr('href'),
|
|
||||||
}))
|
|
||||||
.get();
|
|
||||||
|
|
||||||
const out = await Promise.all(
|
|
||||||
list.map(async (item) => {
|
|
||||||
const itemUrl = url.resolve(host, item.link);
|
|
||||||
const cache = await ctx.cache.get(itemUrl);
|
|
||||||
if (cache) {
|
|
||||||
return Promise.resolve(JSON.parse(cache));
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await axios.get(itemUrl);
|
|
||||||
const $ = cheerio.load(response.data);
|
|
||||||
const single = {
|
|
||||||
title: item.title,
|
|
||||||
link: itemUrl,
|
|
||||||
author: '上海交通大学电子信息与电气工程学院学生工作办公室',
|
|
||||||
description: $('.article_box')
|
|
||||||
.text()
|
.text()
|
||||||
.slice(0, -7),
|
.slice(1, -1),
|
||||||
pubDate: new Date(item.date).toUTCString(),
|
title: $(e)
|
||||||
};
|
.children('a')
|
||||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
.text()
|
||||||
return Promise.resolve(single);
|
.slice(1),
|
||||||
})
|
link: $(e)
|
||||||
);
|
.children('a')
|
||||||
|
.attr('href'),
|
||||||
ctx.state.data = {
|
}))
|
||||||
title: '上海交通大学电子信息与电气工程学院学生办 -- ' + config[type].title,
|
.get()
|
||||||
link,
|
);
|
||||||
item: out,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|||||||
Reference in New Issue
Block a user