UNPKG

rsshub

Version:
76 lines (74 loc) 2.25 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import "./helpers-DxBp0Pty.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { load } from "cheerio"; //#region lib/routes/dhu/jiaowu/news.ts const baseUrl = "https://jw.dhu.edu.cn"; const map = { student: "/tzggwxszl/list.htm", teacher: "/tzggwjszl/list.htm", class: "/tzggwxkzl_19850/list.htm", fxzy: "/fxzy/list.htm" }; const route = { path: "/jiaowu/news/:type?", categories: ["university"], example: "/dhu/jiaowu/news/student", parameters: { type: "默认为 `student`" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, name: "教务处通知", maintainers: ["KiraKiseki"], handler, description: `| 学生专栏 | 教师专栏 | 选课专栏(仅选课期间开放) | 辅修专业 | | -------- | -------- | -------- | -------- | | student | teacher | class | fxzy |` }; async function handler(ctx) { const link = `${baseUrl}${map[ctx.req.param("type") || "student"]}`; const { data: response } = await got_default(link); const $ = load(response); const items = await Promise.all($(".list2 > li").toArray().map(async (item) => { item = $(item); const newsTitle = item.find(".news_title > a"); const newsMeta = item.find(".news_meta"); const link$1 = newsTitle.attr("href"); const title = newsTitle.text(); const pubDate = parseDate(newsMeta.text(), "YYYY-MM-DD", "zh-cn"); const url = `${baseUrl}${link$1}`; return await cache_default.tryGet(url, async () => { let description = ""; try { const { data: response$1 } = await got_default(url); description = load(response$1)(".wp_articlecontent").first().html() ?? ""; } catch { description = ""; } return { title, link: link$1, pubDate, description }; }); })); return { title: "东华大学教务处-" + $(".col_title").text(), link, item: items }; } //#endregion export { route };