UNPKG

rsshub

Version:
61 lines (59 loc) 2.17 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import "./helpers-DxBp0Pty.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { t as timezone } from "./timezone-D8cuwzTY.mjs"; import { load } from "cheerio"; //#region lib/routes/gov/huizhou/zwgk/index.ts const rootURL = "http://www.huizhou.gov.cn"; const route = { path: "/huizhou/zwgk/:category?", categories: ["government"], example: "/gov/huizhou/zwgk/jgdt", parameters: { category: "资讯类别,可以从网址中得到,默认为政务要闻" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, name: "惠州市人民政府", maintainers: ["Fatpandac"], handler, description: `#### 政务公开 {#guang-dong-sheng-ren-min-zheng-fu-hui-zhou-shi-ren-min-zheng-fu-zheng-wu-gong-kai}` }; async function handler(ctx) { const url = `${rootURL}/zwgk/hzsz/${ctx.req.param("category") ?? "zwyw"}`; const $ = load((await got_default(url)).data); const title = $("span#navigation").children("a").last().text(); const list = $("ul.ul_art_row").toArray().map((item) => ({ title: $(item).find("a").text().trim(), link: $(item).find("a").attr("href"), pubDate: timezone(parseDate($(item).find("li.li_art_date").text().trim()), 8) })); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const content = load((await got_default(item.link)).data); try { item.description = content("div.artContent").html(); item.author = content("div.info_fbt").find("span.ly").text().match(/来源:(.*)/)[1]; item.pubDate = timezone(parseDate(content("div.info_fbt").find("span.time").text().match(/时间:(.*)/)[1]), 8); } catch { item.description = ""; } return item; }))); return { title: `惠州市人民政府 - ${title}`, link: url, item: items }; } //#endregion export { route };