UNPKG

rsshub

Version:
57 lines (55 loc) 1.94 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import { t as ofetch_default } from "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import { t as timezone } from "./timezone-D8cuwzTY.mjs"; import { load } from "cheerio"; //#region lib/routes/qiche365/recall.ts const baseUrl = "https://www.qiche365.org.cn"; const route = { path: "/recall/:channel", name: "汽车召回", example: "/qiche365/recall/1", parameters: { channel: "频道,见下表" }, description: `| 国内召回新闻 | 国内召回公告 | 国外召回新闻 | 国外召回公告 | | ------------ | ------------ | ------------ | ------------ | | 1 | 2 | 3 | 4 |`, categories: ["government"], maintainers: ["huanfe1"], handler, url: "qiche365.org.cn/index/recall/index.html" }; async function handler(ctx) { const { channel } = ctx.req.param(); const { html } = await ofetch_default(`${baseUrl}/index/recall/index/item/${channel}.html?loadmore=1`, { method: "get", headers: { "Accept-Language": "zh-CN,zh;q=0.9" } }); const $ = load(html); const items = $("li").toArray().map((item) => { const cheerioItem = $(item); return { title: cheerioItem.find("h1").text(), link: `${baseUrl}${cheerioItem.find("a").attr("href")}`, pubDate: timezone(parseDate(cheerioItem.find("h2").html().match("</i>(.*?)<b>")[1]), 8), description: cheerioItem.find("p").text().trim(), author: cheerioItem.find("h3 span").text(), image: cheerioItem.find("img").attr("src") && `${baseUrl}${cheerioItem.find("img").attr("src")}` }; }); return { title: [ "国内召回公告", "国内召回新闻", "国外召回公告", "国外召回新闻" ][channel - 1], link: `${baseUrl}/index/recall/index.html`, item: items, language: "zh-CN" }; } //#endregion export { route };