UNPKG

rsshub

Version:
40 lines (39 loc) 1.15 kB
import { t as rofetch } from "./ofetch-U0CdpE2g.mjs"; import { t as parseDate } from "./parse-date-3kcy2Eau.mjs"; import { t as timezone } from "./timezone-UiMFOuvL.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 response = await rofetch(link); const $ = load(response); 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 };