diff --git a/lib/routes/szftedu/dongtai.ts b/lib/routes/szftedu/dongtai.ts new file mode 100644 index 0000000000000..c2acc657f0efc --- /dev/null +++ b/lib/routes/szftedu/dongtai.ts @@ -0,0 +1,62 @@ +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 host = 'https://ylxx.szftedu.cn/xx_5828/xydt_5829/bxfbx_6371/'; +const baseLink = 'https://ylxx.szftedu.cn'; + +export const route: Route = { + path: '/dongtai', + categories: ['university'], + example: '/szftedu/dongtai', + parameters: {}, + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: false, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + name: '动态', + maintainers: ['valuex'], + handler, + description: '', +}; + +async function handler() { + const link = host; + const response = await got(link); + const $ = load(response.data); + const lists = $('div.pagenews04 div ul li') + .toArray() + .map((el) => ({ + title: $('a', el).text().trim(), + link: $('a', el).attr('href'), + pubDate: timezone(parseDate($('span[class=canedit]', el).text()), 8), + })); + + const items = await Promise.all( + lists.map((item) => + cache.tryGet(item.link, async () => { + const thisUrl = item.link; + const trueLink = thisUrl.includes('http') ? thisUrl : baseLink + thisUrl; + const response = await got(trueLink); + const $ = load(response.data); + item.description = thisUrl.includes('http') ? $('#page-content').html() : $('div.TRS_Editor').html(); + item.pubDate = timezone(parseDate($('#publish_time').first().text()), 8); + return item; + }) + ) + ); + + return { + title: '园岭小学动态', + link: host, + description: '园岭小学动态', + item: items, + }; +} diff --git a/lib/routes/szftedu/gonggao.ts b/lib/routes/szftedu/gonggao.ts new file mode 100644 index 0000000000000..0cda89550ff0b --- /dev/null +++ b/lib/routes/szftedu/gonggao.ts @@ -0,0 +1,62 @@ +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 host = 'https://ylxx.szftedu.cn/xx_5828/xygg_5832/'; + +export const route: Route = { + path: '/gonggao', + categories: ['university'], + example: '/szftedu/gonggao', + parameters: {}, + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: false, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + name: '公告', + maintainers: ['valuex'], + handler, + description: '', +}; + +async function handler() { + const link = host; + const response = await got(link); + const $ = load(response.data); + + const lists = $('div.pagenews04 div ul li') + .toArray() + .map((el) => ({ + title: $('a', el).text().trim(), + link: $('a', el).attr('href'), + pubDate: timezone(parseDate($('span[class=canedit]', el).text()), 8), + })); + + const items = await Promise.all( + lists.map((item) => + cache.tryGet(item.link, async () => { + const thisUrl = item.link; + const trueLink = thisUrl.includes('http') ? thisUrl : host + thisUrl.substring(1); + const response = await got(trueLink); + const $ = load(response.data); + item.description = thisUrl.includes('http') ? $('#page-content').html() : $('div.TRS_Editor').html(); + item.pubDate = timezone(parseDate($('.item').first().text().replace('发布时间:', '')), 8); + return item; + }) + ) + ); + + return { + title: '园岭小学公告', + link: host, + description: '园岭小学公告', + item: items, + }; +} diff --git a/lib/routes/szftedu/namespace.ts b/lib/routes/szftedu/namespace.ts new file mode 100644 index 0000000000000..26f718b052ae0 --- /dev/null +++ b/lib/routes/szftedu/namespace.ts @@ -0,0 +1,6 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '园岭小学', + url: 'ylxx.szftedu.cn', +};