UNPKG

rsshub

Version:
62 lines (60 loc) 1.94 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 "./helpers-Bo4JQYdN.mjs"; import { t as got_default } from "./got-CO-ndVl2.mjs"; import { t as timezone } from "./timezone-CA9Huotp.mjs"; import { t as invalid_parameter_default } from "./invalid-parameter-ByDtry1B.mjs"; import { load } from "cheerio"; //#region lib/routes/gov/shenzhen/zjj/index.ts const config = { tzgg: { link: "tzgg/", title: "通知公告" } }; const route = { path: "/shenzhen/zjj/xxgk/:caty", categories: ["government"], example: "/gov/shenzhen/zjj/xxgk/tzgg", parameters: { caty: "信息类别" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["zjj.sz.gov.cn/xxgk/:caty"] }], name: "深圳市住房和建设局", maintainers: ["lonn"], handler, description: `| 通知公告 | | :------: | | tzgg |` }; async function handler(ctx) { const baseUrl = "http://zjj.sz.gov.cn/xxgk/"; const cfg = config[ctx.req.param("caty")]; if (!cfg) throw new invalid_parameter_default("Bad category. See <a href=\"https://docs.rsshub.app/routes/government#guang-dong-sheng-ren-min-zheng-fu-shen-zhen-shi-zhu-fang-he-jian-she-ju\">docs</a>"); const currentUrl = new URL(cfg.link, baseUrl).href; const { data: response } = await got_default(currentUrl); const $ = load(response); const items = $("div.listcontent_right ul li").toArray().map((item) => { item = $(item); const a = item.find("a").first(); return { title: a.text(), link: a.attr("href"), pubDate: timezone(parseDate(item.find("span").first().text(), "YY-MM-DD"), 0) }; }); return { title: "深圳市住房和建设局 - " + cfg.title, link: currentUrl, item: items }; } //#endregion export { route };