UNPKG

rsshub

Version:
43 lines (42 loc) 1.55 kB
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs"; import { t as parseDate } from "./parse-date-CjhZE69i.mjs"; import { t as cache_default } from "./cache-CiDoUSLo.mjs"; import { t as timezone } from "./timezone-DE--ze1V.mjs"; import { load } from "cheerio"; //#region lib/routes/gov/mohurd/policy.ts const route = { path: "/policy", categories: ["government"], example: "/gov/mohurd/policy", radar: [{ source: ["www.mohurd.gov.cn/zhengcefabu/index.html"] }], name: "政策发布", maintainers: ["nczitzk"], handler, url: "www.mohurd.gov.cn/zhengcefabu/index.html" }; async function handler() { const baseUrl = "https://www.mohurd.gov.cn"; const link = `${baseUrl}/zhengcefabu/index.html`; const script = load(await rofetch(link))("script[src*=\"unitbuild.js\"]"); const query = JSON.parse(script.attr("querydata").replaceAll("'", "\"")); const $ = load((await rofetch(new URL(script.attr("url"), baseUrl).href, { query })).data.html); const list = $("li.date").toArray().map((item) => { const $item = $(item); const a = $item.find("a"); return { title: a.text(), link: new URL(a.attr("href"), baseUrl).href, pubDate: timezone(parseDate($item.find(".date-info").text()), 8) }; }).slice(0, 1); return { title: "中华人民共和国住房和城乡建设部 - 政策发布", link, item: await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { item.description = load(await rofetch(item.link))(".editor-content").html(); return item; }))) }; } //#endregion export { route };