feat(route): add ECNU Software Engineering Insitute notices route (#20531)
* fix(route): fix wrong title of /ecnu/bksy Co-authored-by: FrozenStarrrr <frozenstars@qq.com> * feat(route): add ECNU Software Engineering Insitute notices route * fix(route): modify wrong radar target --------- Co-authored-by: FrozenStarrrr <frozenstars@qq.com>
This commit is contained in:
parent
fcdc31a7b3
commit
28bc65d0be
|
|
@ -14,7 +14,7 @@ export const route: Route = {
|
|||
radar: [
|
||||
{
|
||||
source: ['bksy.ecnu.edu.cn'],
|
||||
target: '/tzgg',
|
||||
target: '/bksy',
|
||||
},
|
||||
],
|
||||
name: '本科生院通知',
|
||||
|
|
@ -29,7 +29,7 @@ export const route: Route = {
|
|||
.map((el) => ({
|
||||
pubDate: timezone(parseDate($(el).find('.news_date').text()), 8),
|
||||
link: new URL($(el).find('a').attr('href'), baseUrl).toString(),
|
||||
title: $(el).find('a').text(),
|
||||
title: $(el).find('.news_title').text(),
|
||||
}));
|
||||
const items = await Promise.all(
|
||||
links.map((item) =>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,63 @@
|
|||
import { Route } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
const type = (filename) => filename.split('.').pop();
|
||||
|
||||
export const route: Route = {
|
||||
path: '/sei',
|
||||
categories: ['university'],
|
||||
example: '/ecnu/sei',
|
||||
radar: [
|
||||
{
|
||||
source: ['sei.ecnu.edu.cn'],
|
||||
target: '/sei',
|
||||
},
|
||||
],
|
||||
name: '软件工程学院通知公告',
|
||||
maintainers: ['ChiyoYuki', 'ECNU-minus'],
|
||||
handler: async () => {
|
||||
const baseUrl = 'https://sei.ecnu.edu.cn/';
|
||||
|
||||
const response = await got(`${baseUrl}33171/list.htm`);
|
||||
const $ = load(response.data);
|
||||
const links = $('ul.data-list > li')
|
||||
.toArray()
|
||||
.map((el) => ({
|
||||
pubDate: timezone(parseDate($(el).find('.data-list-time').text()), 8),
|
||||
link: new URL($(el).find('a').attr('href'), baseUrl).toString(),
|
||||
title: $(el).find('a').text(),
|
||||
}));
|
||||
const items = await Promise.all(
|
||||
links.map((item) =>
|
||||
cache.tryGet(item.link, async () => {
|
||||
if (type(item.link) === 'htm') {
|
||||
try {
|
||||
const { data } = await got(item.link);
|
||||
const $ = load(data);
|
||||
item.description = $('div.right-nr')?.html()?.replaceAll('src="/', `src="${baseUrl}/`)?.replaceAll('href="/', `href="${baseUrl}/`)?.trim();
|
||||
return item;
|
||||
} catch {
|
||||
// intranet
|
||||
item.description = '请进行统一身份认证之后再访问';
|
||||
return item;
|
||||
}
|
||||
} else {
|
||||
// file to download
|
||||
item.description = '点击认证后访问内容';
|
||||
return item;
|
||||
}
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
return {
|
||||
title: '软件工程学院通知公告',
|
||||
link: 'http://www.sei.ecnu.edu.cn/33171/list.htm',
|
||||
item: items,
|
||||
};
|
||||
},
|
||||
};
|
||||
Loading…
Reference in New Issue