fix: ignore shmtu ssl verification & migrate to route v2 (#11403)
* ignore shmtu ssl verification * migrate route v1 to v2 * fix: add missing radar and maintainer
This commit is contained in:
parent
51ec49d0de
commit
3706b428b8
|
|
@ -569,9 +569,9 @@ router.get('/thu/:type', lazyloadRouteHandler('./routes/universities/thu/index')
|
|||
// router.get('/pku/bbs/hot', lazyloadRouteHandler('./routes/universities/pku/bbs/hot'));
|
||||
// router.get('/pku/scc/recruit/:type?', lazyloadRouteHandler('./routes/universities/pku/scc/recruit'));
|
||||
|
||||
// 上海海事大学
|
||||
router.get('/shmtu/www/:type', lazyloadRouteHandler('./routes/universities/shmtu/www'));
|
||||
router.get('/shmtu/jwc/:type', lazyloadRouteHandler('./routes/universities/shmtu/jwc'));
|
||||
// 上海海事大学 migrated to v2
|
||||
// router.get('/shmtu/www/:type', lazyloadRouteHandler('./routes/universities/shmtu/www'));
|
||||
// router.get('/shmtu/jwc/:type', lazyloadRouteHandler('./routes/universities/shmtu/jwc'));
|
||||
|
||||
// 上海海洋大学
|
||||
router.get('/shou/www/:type', lazyloadRouteHandler('./routes/universities/shou/www'));
|
||||
|
|
|
|||
|
|
@ -1,75 +0,0 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const url = require('url');
|
||||
const host = 'https://jwc.shmtu.edu.cn';
|
||||
|
||||
async function load(link) {
|
||||
const response = await got.get(link);
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
$('.field-item img').each((index, elem) => {
|
||||
const $elem = $(elem);
|
||||
const src = $elem.attr('src');
|
||||
if (src) {
|
||||
$elem.attr('src', url.resolve(host, src));
|
||||
}
|
||||
$elem.removeAttr('style');
|
||||
$elem.removeAttr('alt');
|
||||
});
|
||||
|
||||
const description = $('.field-item').html();
|
||||
|
||||
return { description };
|
||||
}
|
||||
|
||||
const ProcessFeed = (list, caches) =>
|
||||
Promise.all(
|
||||
list.map(async (item) => {
|
||||
const $ = cheerio.load(item);
|
||||
|
||||
const itemUrl = url.resolve(host, $('.views-field-nothing', item).find('a').attr('href'));
|
||||
const category = $('.views-field-field-xxlb', item).text().trim();
|
||||
const author = $('.views-field-field-xxly', item).text().trim();
|
||||
|
||||
const single = {
|
||||
title: $('.views-field-nothing', item).text().trim(),
|
||||
link: itemUrl,
|
||||
guid: itemUrl,
|
||||
pubDate: new Date($('.views-field-created', item).text()).toUTCString(),
|
||||
category,
|
||||
author: author === '' ? category : author,
|
||||
};
|
||||
|
||||
const other = await caches.tryGet(itemUrl, () => load(itemUrl));
|
||||
|
||||
return Promise.resolve(Object.assign({}, single, other));
|
||||
})
|
||||
);
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const type = ctx.params.type;
|
||||
const limit = ctx.query.limit || 4;
|
||||
const info = type === 'jwgg' ? '教务公告' : '教务新闻';
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: host + `/${type}/list.htm`,
|
||||
headers: {
|
||||
Referer: host,
|
||||
},
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('tr', 'tbody')
|
||||
.slice(0, limit > 15 ? 15 : limit)
|
||||
.get();
|
||||
|
||||
const result = await ProcessFeed(list, ctx.cache);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `上海海事大学 ${info}`,
|
||||
link: host + `/${type}`,
|
||||
description: '上海海事大学 教务信息',
|
||||
item: result,
|
||||
};
|
||||
};
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const url = require('url');
|
||||
const host = 'http://www.shmtu.edu.cn';
|
||||
|
||||
async function load(link) {
|
||||
const response = await got.get(link);
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const description = $('meta[name="description"]').attr('content');
|
||||
|
||||
return { description };
|
||||
}
|
||||
|
||||
const ProcessFeed = (list, caches) =>
|
||||
Promise.all(
|
||||
list.map(async (item) => {
|
||||
const $ = cheerio.load(item);
|
||||
|
||||
const itemUrl = url.resolve(host, $('.title', item).find('a').attr('href'));
|
||||
const category = $('.department', item).text().trim();
|
||||
|
||||
const single = {
|
||||
title: $('.title', item).text().trim(),
|
||||
link: itemUrl,
|
||||
guid: itemUrl,
|
||||
pubDate: new Date($('.date', item).find('span').find('span').attr('content')).toUTCString(),
|
||||
category,
|
||||
author: category,
|
||||
};
|
||||
|
||||
const other = await caches.tryGet(itemUrl, () => load(itemUrl));
|
||||
|
||||
return Promise.resolve(Object.assign({}, single, other));
|
||||
})
|
||||
);
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const type = ctx.params.type;
|
||||
const info = type === 'notes' ? '通知公告' : '学术讲座';
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: host + `/${type}`,
|
||||
headers: {
|
||||
Referer: host,
|
||||
},
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('tr', 'tbody').slice(0, 10).get();
|
||||
|
||||
const result = await ProcessFeed(list, ctx.cache);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `上海海事大学 ${info}`,
|
||||
link: host + `/${type}`,
|
||||
description: '上海海事大学 官网信息',
|
||||
item: result,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const host = 'https://jwc.shmtu.edu.cn';
|
||||
|
||||
async function load(link) {
|
||||
const response = await got(link, { https: { rejectUnauthorized: false } });
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
return $('.wp_articlecontent').html();
|
||||
}
|
||||
|
||||
const ProcessFeed = (list, caches) =>
|
||||
Promise.all(
|
||||
list.map((item) =>
|
||||
caches.tryGet(item.link, async () => {
|
||||
item.description = await load(item.link);
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const type = ctx.params.type;
|
||||
const info = type === 'jwgg' ? '教务公告' : '教务新闻';
|
||||
|
||||
const response = await got(`${host}/${type}/list.htm`, {
|
||||
headers: {
|
||||
Referer: host,
|
||||
},
|
||||
https: { rejectUnauthorized: false },
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('tbody tr')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.find('.views-field-nothing a').attr('title').trim(),
|
||||
link: new URL(item.find('a').attr('href'), host).href,
|
||||
pubDate: timezone(parseDate(item.find('.pubdate').text()), 8),
|
||||
category: item.find('.views-field-field-xxlb').text(),
|
||||
author: item.find('.views-field-field-xxly').text(),
|
||||
};
|
||||
});
|
||||
|
||||
const result = await ProcessFeed(list, ctx.cache);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `上海海事大学 ${info}`,
|
||||
link: `${host}/${type}`,
|
||||
description: '上海海事大学 教务信息',
|
||||
item: result,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = {
|
||||
'/jwc/:type': ['simonsmh'],
|
||||
'/www/:type': ['simonsmh'],
|
||||
};
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
module.exports = {
|
||||
'shmtu.edu.cn': {
|
||||
_name: '上海海事大学',
|
||||
jwc: [
|
||||
{
|
||||
title: '教务信息',
|
||||
docs: 'https://docs.rsshub.app/university.html#shang-hai-dian-li-da-xue',
|
||||
source: ['/:type'],
|
||||
target: '/shmtu/jwc/:type',
|
||||
},
|
||||
],
|
||||
www: [
|
||||
{
|
||||
title: '官网信息',
|
||||
docs: 'https://docs.rsshub.app/university.html#shang-hai-dian-li-da-xue',
|
||||
source: ['/:type'],
|
||||
target: '/shmtu/www/:type',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = (router) => {
|
||||
router.get('/jwc/:type', require('./jwc'));
|
||||
router.get('/www/:type', require('./www'));
|
||||
};
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const host = 'https://www.shmtu.edu.cn';
|
||||
|
||||
async function load(link) {
|
||||
const response = await got.get(link, { https: { rejectUnauthorized: false } });
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
return $('article').html();
|
||||
}
|
||||
|
||||
const ProcessFeed = (list, caches) =>
|
||||
Promise.all(
|
||||
list.map((item) =>
|
||||
caches.tryGet(item.link, async () => {
|
||||
item.description = await load(item.link);
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const type = ctx.params.type;
|
||||
const info = type === 'notes' ? '通知公告' : '学术讲座';
|
||||
|
||||
const response = await got(`${host}/${type}`, {
|
||||
headers: {
|
||||
Referer: host,
|
||||
},
|
||||
https: { rejectUnauthorized: false },
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('tbody tr')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
const category = item.find('.department').text().trim();
|
||||
return {
|
||||
title: item.find('.title a').text().trim(),
|
||||
link: new URL(item.find('a').attr('href'), host).href,
|
||||
pubDate: parseDate(item.find('.date-display-single').attr('content')),
|
||||
category,
|
||||
author: category,
|
||||
};
|
||||
});
|
||||
|
||||
const result = await ProcessFeed(list, ctx.cache);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `上海海事大学 ${info}`,
|
||||
link: `${host}/${type}`,
|
||||
description: '上海海事大学 官网信息',
|
||||
item: result,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue