rsshub
Version:
Make RSS Great Again!
48 lines (47 loc) • 1.31 kB
JavaScript
import { t as parseDate } from "./parse-date-3kcy2Eau.mjs";
import { t as got_default } from "./got-DUpa1V3-.mjs";
import { t as namespace } from "./namespace-y0YEP6Cr.mjs";
import { load } from "cheerio";
//#region lib/routes/sxhm/announcement.ts
const route = {
path: "/announcement",
categories: ["travel"],
example: "/sxhm/announcement",
parameters: {},
name: "Announcements",
maintainers: ["magazian"],
radar: [{
source: ["www.sxhm.com/info/announcement.html"],
target: "/announcement"
}],
handler: async () => {
const baseUrl = "https://www.sxhm.com";
const apiUrl = `${baseUrl}/info/announcement.html`;
const museumName = namespace.zh?.name || namespace.name;
const response = await got_default({
method: "get",
url: apiUrl
});
const $ = load(response.data);
const items = $(".listwrap .list .li").toArray().map((el) => {
const $item = $(el);
const $a = $item.find(".ltit a");
const title = $item.find(".ltit .t").text();
const link = new URL($a.attr("href"), baseUrl).href;
const dateStr = $item.find(".lcont .date").text();
return {
title,
link,
pubDate: parseDate(dateStr)
};
});
return {
title: `${museumName} - 最新公告`,
link: apiUrl,
language: "zh-CN",
item: items
};
}
};
//#endregion
export { route };