UNPKG

rsshub

Version:
69 lines (68 loc) 2.27 kB
import { t as rofetch } from "./ofetch-C3ts-Hud.mjs"; import { t as parseDate } from "./parse-date-Cr0wQjV_.mjs"; import { t as cache_default } from "./cache-BkqOokyU.mjs"; import { t as timezone } from "./timezone-BBvDwS_3.mjs"; import { load } from "cheerio"; //#region lib/routes/tsinghua/thuhs.ts const categoryMap = { tzgg: "通知公告", xstd: "学生活动", jsfc: "教师风采", xwdt: "新闻动态" }; const route = { path: "/thuhs/:category?", categories: ["university"], example: "/tsinghua/thuhs/tzgg", parameters: { category: "分类,见下表,留空则默认获取通知公告" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["www.qhfz.edu.cn/:category.htm"] }], name: "附属中学", maintainers: ["Aquarius-Situla"], handler, description: `| 通知公告 | 学生活动 | 教师风采 | 新闻动态 | | -------- | -------- | -------- | -------- | | tzgg | xstd | jsfc | xwdt |` }; async function handler(ctx) { const category = ctx.req.param("category") || "tzgg"; const host = "https://www.qhfz.edu.cn"; const targetUrl = `${host}/${category}.htm`; const $ = load(await rofetch(targetUrl)); const items = $(".list ul li, .list_tt ul li").toArray().map((item) => { const $item = $(item); const $a = $item.find("a"); const title = $a.attr("title") || $a.text(); const time = $item.find(".sj").text(); const link = $a.attr("href"); return { title: title.trim(), link: link ? new URL(link, targetUrl).href : "", pubDate: time ? timezone(parseDate(time, "YYYY-MM-DD"), 8) : void 0 }; }).filter((item) => item.link); const feedTitle = categoryMap[category] || "通知公告"; const out = await Promise.all(items.map((item) => cache_default.tryGet(item.link, async () => { if (new URL(item.link).hostname !== "www.qhfz.edu.cn") return item; item.description = load(await rofetch(item.link))(".v_news_content").html() || ""; return item; }))); const icon = new URL("images/logo.png", host).href; return { title: `清华附中 - ${feedTitle}`, link: targetUrl, item: out, image: icon, icon, logo: icon }; } //#endregion export { route };