feat(route): add some insitutes' routes of ECNU (#20532)

* 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

* add School of Computer Science and Technology ECNU notices route

* add School of data science and engineering notices route

* add School of Comm. & Elec. Engineering notices route

* add School of Geospace A.I. Engineering ECNU notices route

* add ECNU faculty of Edu. notices route

* add ECNU faculty of Earth Sci. notices route

* add ECNU Meng Xiancheng notices route

* add ECNU Guanghua notices route

* fix(route): add empty line at the end of files.

* add department of history ECNU notices route

* add department of Philo. ECNU notices route

* fix(route): add maintainer of /ecnu/bksy

* fix(route): delete unnecessary try-catch statment, modified incorrect url, fix image url.

* fix(route): fix unnecessary try-catch, description, condition and wrond url

* fix(route): fix image display

* fix(route): fix problems in bksy.ts

---------

Co-authored-by: FrozenStarrrr <frozenstars@qq.com>
This commit is contained in:
千代有希=
2025-11-22 22:06:51 +08:00
committed by GitHub
co-authored by FrozenStarrrr
parent 6eb460c33b
commit e0aee671fb
13 changed files with 690 additions and 38 deletions
+14 -19
View File
@@ -5,8 +5,6 @@ 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: '/bksy',
categories: ['university'],
@@ -18,7 +16,7 @@ export const route: Route = {
},
],
name: '本科生院通知',
maintainers: ['ChiyoYuki', 'FrozenStarrrr'],
maintainers: ['FrozenStarrrr', 'ChiyoYuki', 'ECNU-minus'],
handler: async () => {
const baseUrl = 'https://bksy.ecnu.edu.cn/';
@@ -27,29 +25,26 @@ export const route: Route = {
const links = $('ul.news_list.list2 > li')
.toArray()
.map((el) => ({
pubDate: timezone(parseDate($(el).find('.news_date').text()), 8),
pubDate: timezone(parseDate($(el).find('.news_date').text()), +8),
link: new URL($(el).find('a').attr('href'), baseUrl).toString(),
title: $(el).find('.news_title').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.article')?.html()?.replaceAll('src="/', `src="${baseUrl}/`)?.replaceAll('href="/', `href="${baseUrl}/`)?.trim();
return item;
} catch {
// intranet
item.description = '请进行统一身份认证之后再访问';
return item;
const { data } = await got(item.link);
const $ = load(data);
const $read = $('div.read');
$read.find('img[src], a[href]').each((i, el) => {
const $el = $(el);
const attr = el.tagName === 'img' ? 'src' : 'href';
const val = $el.attr(attr);
if (val) {
$el.attr(attr, new URL(val, baseUrl).toString());
}
} else {
// file to download
item.description = '点击认证后访问内容';
return item;
}
});
item.description = $read.html()?.trim();
return item;
})
)
);
+58
View File
@@ -0,0 +1,58 @@
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';
export const route: Route = {
path: '/cee',
categories: ['university'],
example: '/ecnu/cee',
radar: [
{
source: ['cee.ecnu.edu.cn'],
target: '/cee',
},
],
name: '通信与电子工程学院通知公告',
maintainers: ['FrozenStarrrr', 'ChiyoYuki', 'ECNU-minus'],
handler: async () => {
const baseUrl = 'https://cee.ecnu.edu.cn/';
const response = await got(`${baseUrl}tzgg_4170/list.htm`);
const $ = load(response.data);
const links = $('ul.news_list.list2 > li')
.toArray()
.map((el) => ({
pubDate: timezone(parseDate($(el).find('.news_meta').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 () => {
const { data } = await got(item.link);
const $ = load(data);
const $read = $('div.read');
$read.find('img[src], a[href]').each((i, el) => {
const $el = $(el);
const attr = el.tagName === 'img' ? 'src' : 'href';
const val = $el.attr(attr);
if (val) {
$el.attr(attr, new URL(val, baseUrl).toString());
}
});
item.description = $read.html()?.trim();
return item;
})
)
);
return {
title: '通信与电子工程学院通知公告',
link: 'https://cee.ecnu.edu.cn/tzgg_4170/list.htm',
item: items,
};
},
};
+58
View File
@@ -0,0 +1,58 @@
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';
export const route: Route = {
path: '/cs',
categories: ['university'],
example: '/ecnu/cs',
radar: [
{
source: ['cs.ecnu.edu.cn'],
target: '/cs',
},
],
name: '计算机科学与技术学院通知公告',
maintainers: ['FrozenStarrrr', 'ChiyoYuki', 'ECNU-minus'],
handler: async () => {
const baseUrl = 'https://cs.ecnu.edu.cn/';
const response = await got(`${baseUrl}19867/list.htm`);
const $ = load(response.data);
const links = $('div#wp_news_w6 ul.data-list > li')
.toArray()
.map((el) => ({
pubDate: timezone(parseDate($(el).find('span').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 () => {
const { data } = await got(item.link);
const $ = load(data);
const $read = $('div.view-cnt');
$read.find('img[src], a[href]').each((i, el) => {
const $el = $(el);
const attr = el.tagName === 'img' ? 'src' : 'href';
const val = $el.attr(attr);
if (val) {
$el.attr(attr, new URL(val, baseUrl).toString());
}
});
item.description = $read.html()?.trim();
return item;
})
)
);
return {
title: '计算机科学与技术学院通知公告',
link: 'https://cs.ecnu.edu.cn/19867/list.htm',
item: items,
};
},
};
+58
View File
@@ -0,0 +1,58 @@
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';
export const route: Route = {
path: '/dase',
categories: ['university'],
example: '/ecnu/dase',
radar: [
{
source: ['dase.ecnu.edu.cn'],
target: '/dase',
},
],
name: '数据科学与工程学院通知公告',
maintainers: ['FrozenStarrrr', 'ChiyoYuki', 'ECNU-minus'],
handler: async () => {
const baseUrl = 'https://dase.ecnu.edu.cn/';
const response = await got(`${baseUrl}41465/list.htm`);
const $ = load(response.data);
const links = $('ul.news_list.list2 > li')
.toArray()
.map((el) => ({
pubDate: timezone(parseDate($(el).find('.news_meta').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 () => {
const { data } = await got(item.link);
const $ = load(data);
const $read = $('div.read');
$read.find('img[src], a[href]').each((i, el) => {
const $el = $(el);
const attr = el.tagName === 'img' ? 'src' : 'href';
const val = $el.attr(attr);
if (val) {
$el.attr(attr, new URL(val, baseUrl).toString());
}
});
item.description = $read.html()?.trim();
return item;
})
)
);
return {
title: '数据科学与工程学院通知公告',
link: 'https://dase.ecnu.edu.cn/41465/list.htm',
item: items,
};
},
};
+58
View File
@@ -0,0 +1,58 @@
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';
export const route: Route = {
path: '/dx',
categories: ['university'],
example: '/ecnu/dx',
radar: [
{
source: ['dx.ecnu.edu.cn'],
target: '/dx',
},
],
name: '大夏书院通知公告',
maintainers: ['FrozenStarrrr', 'ChiyoYuki', 'ECNU-minus'],
handler: async () => {
const baseUrl = 'https://dx.ecnu.edu.cn/';
const response = await got(`${baseUrl}xydt/list.htm`);
const $ = load(response.data);
const links = $('ul.news_list.list2 > li')
.toArray()
.map((el) => ({
pubDate: timezone(parseDate($(el).find('.news_meta').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 () => {
const { data } = await got(item.link);
const $ = load(data);
const $read = $('div.read');
$read.find('img[src], a[href]').each((i, el) => {
const $el = $(el);
const attr = el.tagName === 'img' ? 'src' : 'href';
const val = $el.attr(attr);
if (val) {
$el.attr(attr, new URL(val, baseUrl).toString());
}
});
item.description = $read.html()?.trim();
return item;
})
)
);
return {
title: '大夏书院通知公告',
link: 'https://dx.ecnu.edu.cn/xydt/list.htm',
item: items,
};
},
};
+66
View File
@@ -0,0 +1,66 @@
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: '/dxb',
categories: ['university'],
example: '/ecnu/dxb',
radar: [
{
source: ['dxb.ecnu.edu.cn'],
target: '/dxb',
},
],
name: '地球科学学部通知公告',
maintainers: ['FrozenStarrrr', 'ChiyoYuki', 'ECNU-minus'],
handler: async () => {
const baseUrl = 'https://dxb.ecnu.edu.cn/';
const response = await got(`${baseUrl}18277/list.htm`);
const $ = load(response.data);
const links = $('ul.news_list > li')
.toArray()
.map((el) => ({
pubDate: timezone(parseDate($(el).find('.news_meta').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') {
const { data } = await got(item.link);
const $ = load(data);
const $read = $('div.read');
$read.find('img[src], a[href]').each((i, el) => {
const $el = $(el);
const attr = el.tagName === 'img' ? 'src' : 'href';
const val = $el.attr(attr);
if (val) {
$el.attr(attr, new URL(val, baseUrl).toString());
}
});
item.description = $read.html()?.trim();
return item;
} else {
// file to download
item.description = '请到原网页访问';
return item;
}
})
)
);
return {
title: '地球科学学部通知公告',
link: 'https://dxb.ecnu.edu.cn/18277/list.htm',
item: items,
};
},
};
+58
View File
@@ -0,0 +1,58 @@
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';
export const route: Route = {
path: '/ed',
categories: ['university'],
example: '/ecnu/ed',
radar: [
{
source: ['ed.ecnu.edu.cn'],
target: '/ed',
},
],
name: '教育学部通知公告',
maintainers: ['FrozenStarrrr', 'ChiyoYuki', 'ECNU-minus'],
handler: async () => {
const baseUrl = 'https://ed.ecnu.edu.cn/';
const response = await got(`${baseUrl}45918/list.htm`);
const $ = load(response.data);
const links = $('ul.news_list.list2 > li')
.toArray()
.map((el) => ({
pubDate: timezone(parseDate($(el).find('.news_meta').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 () => {
const { data } = await got(item.link);
const $ = load(data);
const $read = $('div.read');
$read.find('img[src], a[href]').each((i, el) => {
const $el = $(el);
const attr = el.tagName === 'img' ? 'src' : 'href';
const val = $el.attr(attr);
if (val) {
$el.attr(attr, new URL(val, baseUrl).toString());
}
});
item.description = $read.html()?.trim();
return item;
})
)
);
return {
title: '教育学部通知公告',
link: 'https://ed.ecnu.edu.cn/45918/list.htm',
item: items,
};
},
};
+66
View File
@@ -0,0 +1,66 @@
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: '/geoai',
categories: ['university'],
example: '/ecnu/geoai',
radar: [
{
source: ['geoai.ecnu.edu.cn'],
target: '/geoai',
},
],
name: '空间人工智能学院通知公告',
maintainers: ['FrozenStarrrr', 'ChiyoYuki', 'ECNU-minus'],
handler: async () => {
const baseUrl = 'https://geoai.ecnu.edu.cn/';
const response = await got(`${baseUrl}tzgg/list.htm`);
const $ = load(response.data);
const links = $('ul.news_list > li')
.toArray()
.map((el) => ({
pubDate: timezone(parseDate($(el).find('.news_meta').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') {
const { data } = await got(item.link);
const $ = load(data);
const $read = $('div.wp_articlecontent');
$read.find('img[src], a[href]').each((i, el) => {
const $el = $(el);
const attr = el.tagName === 'img' ? 'src' : 'href';
const val = $el.attr(attr);
if (val) {
$el.attr(attr, new URL(val, baseUrl).toString());
}
});
item.description = $read.html()?.trim();
return item;
} else {
// file to download
item.description = '点击认证后访问内容';
return item;
}
})
)
);
return {
title: '空间人工智能学院通知公告',
link: 'https://geoai.ecnu.edu.cn/tzgg/list.htm',
item: items,
};
},
};
+66
View File
@@ -0,0 +1,66 @@
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: '/ghcollege',
categories: ['university'],
example: '/ecnu/ghcollege',
radar: [
{
source: ['www.ghcollege.ecnu.edu.cn'],
target: '/ghcollege',
},
],
name: '光华书院通知公告',
maintainers: ['FrozenStarrrr', 'ChiyoYuki', 'ECNU-minus'],
handler: async () => {
const baseUrl = 'http://www.ghcollege.ecnu.edu.cn/';
const response = await got(`${baseUrl}8609/list.htm`);
const $ = load(response.data);
const links = $('ul.wp_article_list > li')
.toArray()
.map((el) => ({
pubDate: timezone(parseDate($(el).find('.Article_PublishDate').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') {
const { data } = await got(item.link);
const $ = load(data);
const $read = $('div.wp_articlecontent');
$read.find('img[src], a[href]').each((i, el) => {
const $el = $(el);
const attr = el.tagName === 'img' ? 'src' : 'href';
const val = $el.attr(attr);
if (val) {
$el.attr(attr, new URL(val, baseUrl).toString());
}
});
item.description = $read.html()?.trim();
return item;
} else {
// file to download
item.description = '请至原网页访问内容';
return item;
}
})
)
);
return {
title: '光华书院通知公告',
link: 'http://www.ghcollege.ecnu.edu.cn/8609/list.htm',
item: items,
};
},
};
+58
View File
@@ -0,0 +1,58 @@
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';
export const route: Route = {
path: '/history',
categories: ['university'],
example: '/ecnu/history',
radar: [
{
source: ['history.ecnu.edu.cn'],
target: '/history',
},
],
name: '历史学系通知公告',
maintainers: ['FrozenStarrrr', 'ChiyoYuki', 'ECNU-minus'],
handler: async () => {
const baseUrl = 'https://history.ecnu.edu.cn/';
const response = await got(`${baseUrl}33433/list.htm`);
const $ = load(response.data);
const links = $('ul.data-list2 > li')
.toArray()
.map((el) => ({
pubDate: timezone(parseDate($(el).find('span').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 () => {
const { data } = await got(item.link);
const $ = load(data);
const $read = $('div.wp_articlecontent');
$read.find('img[src], a[href]').each((i, el) => {
const $el = $(el);
const attr = el.tagName === 'img' ? 'src' : 'href';
const val = $el.attr(attr);
if (val) {
$el.attr(attr, new URL(val, baseUrl).toString());
}
});
item.description = $read.html()?.trim();
return item;
})
)
);
return {
title: '历史学系通知公告',
link: 'https://history.ecnu.edu.cn/33433/list.htm',
item: items,
};
},
};
+58
View File
@@ -0,0 +1,58 @@
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';
export const route: Route = {
path: '/mxcsy',
categories: ['university'],
example: '/ecnu/mxcsy',
radar: [
{
source: ['mxcsy.ecnu.edu.cn'],
target: '/mxcsy',
},
],
name: '孟宪承书院通知公告',
maintainers: ['FrozenStarrrr', 'ChiyoYuki', 'ECNU-minus'],
handler: async () => {
const baseUrl = 'https://mxcsy.ecnu.edu.cn/';
const response = await got(`${baseUrl}29520/list.htm`);
const $ = load(response.data);
const links = $('ul.wp_article_list > li')
.toArray()
.map((el) => ({
pubDate: timezone(parseDate($(el).find('.Article_PublishDate').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 () => {
const { data } = await got(item.link);
const $ = load(data);
const $read = $('div.wp_articlecontent');
$read.find('img[src], a[href]').each((i, el) => {
const $el = $(el);
const attr = el.tagName === 'img' ? 'src' : 'href';
const val = $el.attr(attr);
if (val) {
$el.attr(attr, new URL(val, baseUrl).toString());
}
});
item.description = $read.html()?.trim();
return item;
})
)
);
return {
title: '孟宪承书院通知公告',
link: 'https://mxcsy.ecnu.edu.cn/29520/list.htm',
item: items,
};
},
};
+58
View File
@@ -0,0 +1,58 @@
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';
export const route: Route = {
path: '/philo',
categories: ['university'],
example: '/ecnu/philo',
radar: [
{
source: ['www.philo.ecnu.edu.cn'],
target: '/philo',
},
],
name: '哲学系通知公告',
maintainers: ['FrozenStarrrr', 'ChiyoYuki', 'ECNU-minus'],
handler: async () => {
const baseUrl = 'http://www.philo.ecnu.edu.cn/';
const response = await got(`${baseUrl}tzggw/list.htm`);
const $ = load(response.data);
const links = $('ul.data-list2 > li')
.toArray()
.map((el) => ({
pubDate: timezone(parseDate($(el).find('span').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 () => {
const { data } = await got(item.link);
const $ = load(data);
const $read = $('div.wp_articlecontent');
$read.find('img[src], a[href]').each((i, el) => {
const $el = $(el);
const attr = el.tagName === 'img' ? 'src' : 'href';
const val = $el.attr(attr);
if (val) {
$el.attr(attr, new URL(val, baseUrl).toString());
}
});
item.description = $read.html()?.trim();
return item;
})
)
);
return {
title: '哲学系通知公告',
link: 'http://www.philo.ecnu.edu.cn/tzggw/list.htm',
item: items,
};
},
};
+14 -19
View File
@@ -5,8 +5,6 @@ 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'],
@@ -18,7 +16,7 @@ export const route: Route = {
},
],
name: '软件工程学院通知公告',
maintainers: ['ChiyoYuki', 'ECNU-minus'],
maintainers: ['FrozenStarrrr', 'ChiyoYuki', 'ECNU-minus'],
handler: async () => {
const baseUrl = 'https://sei.ecnu.edu.cn/';
@@ -27,29 +25,26 @@ export const route: Route = {
const links = $('ul.data-list > li')
.toArray()
.map((el) => ({
pubDate: timezone(parseDate($(el).find('.data-list-time').text()), 8),
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;
const { data } = await got(item.link);
const $ = load(data);
const $read = $('div.wp_articlecontent');
$read.find('img[src], a[href]').each((i, el) => {
const $el = $(el);
const attr = el.tagName === 'img' ? 'src' : 'href';
const val = $el.attr(attr);
if (val) {
$el.attr(attr, new URL(val, baseUrl).toString());
}
} else {
// file to download
item.description = '点击认证后访问内容';
return item;
}
});
item.description = $read.html()?.trim();
return item;
})
)
);