UNPKG

rsshub

Version:
39 lines (38 loc) 1.12 kB
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs"; import { t as parseDate } from "./parse-date-CjhZE69i.mjs"; import { t as timezone } from "./timezone-DE--ze1V.mjs"; import { load } from "cheerio"; //#region lib/routes/dlpu/wlfw/news.ts const route = { path: "/wlfw/news/:type?", categories: ["university"], example: "/dlpu/wlfw/news/22", parameters: { type: "默认为 `22`" }, name: "网络服务新闻", maintainers: ["xu42"], handler, description: `| 新闻动态 | 通知公告 | | -------- | -------- | | 22 | 23 |` }; const baseUrl = "https://wlfw.dlpu.edu.cn"; const map = { 22: "/more/22", 23: "/more/23" }; async function handler(ctx) { const { type = "22" } = ctx.req.param(); const link = `${baseUrl}${map[type]}`; const $ = load(await rofetch(link)); return { link, title: $("#main>h1").text(), item: $(".morelist>li").slice(0, 10).toArray().map((elem) => ({ link: new URL($("a", elem).attr("href"), baseUrl).href, title: $("a", elem).attr("title").trim(), pubDate: timezone(parseDate($(".more_time", elem).text()), 8) })) }; } //#endregion export { route };