UNPKG

rsshub

Version:
46 lines (45 loc) 1.65 kB
import { t as rofetch } from "./ofetch-U0CdpE2g.mjs"; import { t as parseDate } from "./parse-date-3kcy2Eau.mjs"; import { t as cache_default } from "./cache-C1Y-9qDV.mjs"; import { t as timezone } from "./timezone-UiMFOuvL.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 indexPage = await rofetch(link); const script = load(indexPage)("script[src*=\"unitbuild.js\"]"); const query = JSON.parse(script.attr("querydata").replaceAll("'", "\"")); const response = await rofetch(new URL(script.attr("url"), baseUrl).href, { query }); const $ = load(response.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 () => { const detailResponse = await rofetch(item.link); item.description = load(detailResponse)(".editor-content").html(); return item; }))) }; } //#endregion export { route };