UNPKG

rsshub

Version:
69 lines (67 loc) 2.16 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 { load } from "cheerio"; //#region lib/routes/samrdprc/news.ts const route = { path: "/news/:type1/:type2", categories: ["government"], example: "/samrdprc/news/xfpzh/xfpgnzh", parameters: { type1: "召回类型ID1,见下表", type2: "召回类型ID2,见下表" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, description: ` | 类型中文 | 召回类型ID1 | 召回类型ID2 | | --- | --- | --- | | 消费品召回 | xfpzh | xfpgnzh | | 汽车召回 | qczh | gnzhqc | `, name: "召回信息", maintainers: ["a180285"], radar: [{ source: ["www.samrdprc.org.cn/:type1/:type2"], target: "/news/:type1/:type2" }], handler: async (ctx) => { const url = `https://www.samrdprc.org.cn/${ctx.req.param("type1")}/${ctx.req.param("type2")}`; const $ = load((await got_default(url)).body); const typeName = $("div.box_main > div.boxl.fl > div.boxl_tit > div > span.fl").text(); const listSelector = $("div.main > div.box1 > div.box_main > div.boxl.fl > div.boxl_ul > ul > li"); const items = await Promise.all(listSelector.toArray().map((el) => { const item = $(el); const title = item.find("a").text(); const link = url + "/" + item.find("a").attr("href"); const pubDate = parseDate(item.find("span").text().trim()); return cache_default.tryGet(link, async () => { return { title, link, pubDate, description: load((await got_default(link)).body)("div.main > div.box1 > div.box_main > div.boxl.fl > div.show_txt > div.TRS_Editor > div").html() || "" }; }); })); return { title: `${typeName} - 国家市场监督管理总局`, link: url, item: items }; } }; //#endregion export { route };