UNPKG

rsshub

Version:
49 lines (48 loc) 1.3 kB
import { t as parseDate } from "./parse-date-3kcy2Eau.mjs"; import { t as got_default } from "./got-DUpa1V3-.mjs"; import { t as namespace } from "./namespace-CuHoQMDK.mjs"; import { load } from "cheerio"; //#region lib/routes/sdmuseum/news.ts const route = { path: "/news", categories: ["travel"], example: "/sdmuseum/news", parameters: {}, name: "News", maintainers: ["magazian"], radar: [{ source: ["www.sdmuseum.com/col/col270324/index.html"], target: "/news" }], handler: async () => { const baseUrl = "https://www.sdmuseum.com"; const apiUrl = `${baseUrl}/col/col270324/index.html`; const museumName = namespace.zh?.name || namespace.name; const response = await got_default({ method: "get", url: apiUrl }); const $ = load(response.data, { xml: true }); const items = $("record").toArray().map((el) => { const itemHtml = $(el).text(); const $item = load(itemHtml); const $a = $item(".ltit a"); const title = $a.attr("title"); const link = new URL($a.attr("href"), baseUrl).href; const dateStr = $item(".data.av").text().trim(); return { title, link, pubDate: parseDate(dateStr) }; }); return { title: `${museumName} - 公告`, link: apiUrl, language: "zh-CN", item: items }; } }; //#endregion export { route };