UNPKG

rsshub

Version:
61 lines (59 loc) 2.17 kB
import "./dist-Bog6z_OM.mjs"; import "./config-MQ-7ebJ_.mjs"; import "./logger-C4avouvV.mjs"; import "./ofetch-DKl_Ma9g.mjs"; import { t as parseDate } from "./parse-date-r5WDWHno.mjs"; import "./is-worker-DESPicPc.mjs"; import { t as cache_default } from "./cache-SV6W5EPy.mjs"; import "./helpers-Bo4JQYdN.mjs"; import { t as got_default } from "./got-CO-ndVl2.mjs"; import { t as timezone } from "./timezone-CA9Huotp.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 };