UNPKG

rsshub

Version:
89 lines (88 loc) 2.69 kB
import { t as parseDate } from "./parse-date-Cr0wQjV_.mjs"; import { t as InvalidParameterError } from "./invalid-parameter-CGxhjomn.mjs"; import { n as outPlaywright } from "./playwright-o20DiLNh.mjs"; import dayjs from "dayjs"; import { load } from "cheerio"; //#region lib/routes/uestc/sise.ts const baseUrl = "https://sise.uestc.edu.cn/"; const mapId = { 1: "notice-1", 2: "notice-2", 3: "notice-3", 4: "notice-4", 5: "notice-5", 6: "notice-6", 7: "notice-7", 8: "notice-8", 9: "notice-9" }; const mapTitle = { 1: "最新", 2: "院办", 3: "学生科", 4: "教务科", 5: "研管科", 6: "组织", 7: "人事", 8: "实践教育中心", 9: "Int'I" }; const route = { path: "/sise/:type?", categories: ["university"], example: "/uestc/sise/1", parameters: { type: "默认为 `1`" }, features: { requireConfig: false, requirePuppeteer: true, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["sise.uestc.edu.cn/"], target: "/sise" }], name: "信息与软件工程学院", maintainers: ["Yadomin", "mobyw"], handler, url: "sise.uestc.edu.cn/", description: `| 最新 | 院办 | 学生科 | 教务科 | 研管科 | 组织 | 人事 | 实践教育中心 | Int'I | | ---- | ---- | ------ | ------ | ------ | ---- | ---- | ------------ | ----- | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |` }; async function handler(ctx) { const type = ctx.req.param("type") || 1; const divId = mapId[type]; if (!divId) throw new InvalidParameterError("type not supported"); const context = await outPlaywright(); const page = await context.newPage(); await page.route("**/*", (route) => { const request = route.request(); request.resourceType() === "document" || request.resourceType() === "script" ? route.continue() : route.abort(); }); await page.goto(baseUrl, { waitUntil: "networkidle" }); const content = await page.content(); await context.close(); const $ = load(content); const out = $($(`div[id="${divId}"] p.news-item`)).toArray().map((item) => { const $item = $(item); const now = dayjs(); let date = dayjs(now.year() + "-" + $item.find("span").text().replace("/", "-")); if (now < date) date = dayjs(now.year() - 1 + "-" + $item.find("span").text().replace("/", "-")); return { title: $item.find("a").text().replace("&amp;", "").trim(), link: baseUrl + $item.find("a").attr("href"), pubDate: parseDate(date.toDate()) }; }); return { title: `信软学院通知-${mapTitle[type]}`, link: baseUrl, description: "电子科技大学信息与软件工程学院通知", item: out }; } //#endregion export { route };