diff --git a/lib/routes/ecnu/bksy.ts b/lib/routes/ecnu/bksy.ts index a921ac280..660c310c9 100644 --- a/lib/routes/ecnu/bksy.ts +++ b/lib/routes/ecnu/bksy.ts @@ -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; }) ) ); diff --git a/lib/routes/ecnu/cee.ts b/lib/routes/ecnu/cee.ts new file mode 100644 index 000000000..b6b1d093e --- /dev/null +++ b/lib/routes/ecnu/cee.ts @@ -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, + }; + }, +}; diff --git a/lib/routes/ecnu/cs.ts b/lib/routes/ecnu/cs.ts new file mode 100644 index 000000000..8eae5c9b0 --- /dev/null +++ b/lib/routes/ecnu/cs.ts @@ -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, + }; + }, +}; diff --git a/lib/routes/ecnu/dase.ts b/lib/routes/ecnu/dase.ts new file mode 100644 index 000000000..fa212dcdb --- /dev/null +++ b/lib/routes/ecnu/dase.ts @@ -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, + }; + }, +}; diff --git a/lib/routes/ecnu/dx.ts b/lib/routes/ecnu/dx.ts new file mode 100644 index 000000000..a263f620a --- /dev/null +++ b/lib/routes/ecnu/dx.ts @@ -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, + }; + }, +}; diff --git a/lib/routes/ecnu/dxb.ts b/lib/routes/ecnu/dxb.ts new file mode 100644 index 000000000..c6e8890b1 --- /dev/null +++ b/lib/routes/ecnu/dxb.ts @@ -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, + }; + }, +}; diff --git a/lib/routes/ecnu/ed.ts b/lib/routes/ecnu/ed.ts new file mode 100644 index 000000000..c556769fe --- /dev/null +++ b/lib/routes/ecnu/ed.ts @@ -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, + }; + }, +}; diff --git a/lib/routes/ecnu/geoai.ts b/lib/routes/ecnu/geoai.ts new file mode 100644 index 000000000..c59d6951f --- /dev/null +++ b/lib/routes/ecnu/geoai.ts @@ -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, + }; + }, +}; diff --git a/lib/routes/ecnu/ghcollege.ts b/lib/routes/ecnu/ghcollege.ts new file mode 100644 index 000000000..74b3f132c --- /dev/null +++ b/lib/routes/ecnu/ghcollege.ts @@ -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, + }; + }, +}; diff --git a/lib/routes/ecnu/history.ts b/lib/routes/ecnu/history.ts new file mode 100644 index 000000000..9b776c044 --- /dev/null +++ b/lib/routes/ecnu/history.ts @@ -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, + }; + }, +}; diff --git a/lib/routes/ecnu/mxcsy.ts b/lib/routes/ecnu/mxcsy.ts new file mode 100644 index 000000000..d51ddf965 --- /dev/null +++ b/lib/routes/ecnu/mxcsy.ts @@ -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, + }; + }, +}; diff --git a/lib/routes/ecnu/philo.ts b/lib/routes/ecnu/philo.ts new file mode 100644 index 000000000..f9796ee17 --- /dev/null +++ b/lib/routes/ecnu/philo.ts @@ -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, + }; + }, +}; diff --git a/lib/routes/ecnu/sei.ts b/lib/routes/ecnu/sei.ts index 738fe8e34..3f073a985 100644 --- a/lib/routes/ecnu/sei.ts +++ b/lib/routes/ecnu/sei.ts @@ -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; }) ) );