UNPKG

rsshub

Version:
69 lines (67 loc) 1.86 kB
import "./dist-Bog6z_OM.mjs"; import "./config-MQ-7ebJ_.mjs"; import "./logger-C4avouvV.mjs"; import "./ofetch-DKl_Ma9g.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 { load } from "cheerio"; //#region lib/routes/gov/chinatax/latest.ts const route = { path: "/chinatax/latest", categories: ["government"], example: "/gov/chinatax/latest", parameters: {}, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["www.chinatax.gov.cn/*"] }], name: "最新文件", maintainers: ["nczitzk", "fuzy112"], handler, url: "www.chinatax.gov.cn/*" }; async function handler() { const link = `http://www.chinatax.gov.cn/chinatax/n810341/n810755/index.html`; const $ = load((await got_default({ method: "get", url: link })).data); const list = $("ul.list.whlist li").slice(0, 10).toArray().map((item) => { item = $(item); const a = item.find("a"); return { title: a.text(), link: new URL(a.attr("href"), `http://www.chinatax.gov.cn`).toString() }; }); return { title: "国家税务总局 - 最新文件", link, item: await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { try { const content = load((await got_default({ method: "get", url: item.link })).data); item.pubDate = content("meta[name=\"PubDate\"]").attr("content"); item.description = content("#fontzoom").html(); return item; } catch (error) { if (error.name === "HTTPError" || error.name === "FetchError") { item.description = error.message; return item; } throw error; } }))) }; } //#endregion export { route };