UNPKG

rsshub

Version:
93 lines (91 loc) 2.79 kB
import "./config-C37vj7VH.mjs"; import "./logger-Czu8UMNd.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import "./proxy-Db7uGcYb.mjs"; import { t as invalid_parameter_default } from "./invalid-parameter-rr4AgGpp.mjs"; import { n as puppeteer_default } from "./puppeteer-DGmvuGvT.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 invalid_parameter_default("type not supported"); const browser = await puppeteer_default(); const page = await browser.newPage(); await page.setRequestInterception(true); page.on("request", (request) => { request.resourceType() === "document" || request.resourceType() === "script" ? request.continue() : request.abort(); }); await page.goto(baseUrl, { waitUntil: "networkidle2" }); const content = await page.content(); await browser.close(); const $ = load(content); const out = $($(`div[id="${divId}"] p.news-item`)).toArray().map((item) => { 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) }; }); return { title: `信软学院通知-${mapTitle[type]}`, link: baseUrl, description: "电子科技大学信息与软件工程学院通知", item: out }; } //#endregion export { route };