UNPKG

rsshub

Version:
69 lines (68 loc) 2.28 kB
import { t as parseDate } from "./parse-date-3kcy2Eau.mjs"; import { t as cache_default } from "./cache-C1Y-9qDV.mjs"; import { t as got_default } from "./got-DUpa1V3-.mjs"; import { t as timezone } from "./timezone-UiMFOuvL.mjs"; import { load } from "cheerio"; import iconv from "iconv-lite"; //#region lib/routes/98zhibo/zuqiujijin.ts const baseUrl = "https://www.98zhibo.com"; const route = { path: "/zuqiujijin", categories: ["sport"], example: "/98zhibo/zuqiujijin", name: "足球集锦", maintainers: ["chouj"], radar: [{ source: ["www.98zhibo.com/zuqiujijin/"], target: "/zuqiujijin" }], handler }; const parsePubDateFromTitle = (title) => { const match = title.match(/^(\d{4})年(\d{1,2})月(\d{1,2})日/); return match ? timezone(parseDate(`${match[1]}-${match[2]}-${match[3]}`), 8) : void 0; }; async function handler() { const currentUrl = `${baseUrl}/zuqiujijin/`; const response = await got_default({ method: "get", url: currentUrl, responseType: "buffer" }); const $ = load(iconv.decode(response.data, "gbk")); const list = $(".list_body_bd li").toArray().map((item) => { const $link = $(item).find("a"); const title = $link.text(); return { title, link: new URL($link.attr("href"), baseUrl).href, pubDate: parsePubDateFromTitle(title) }; }); return { title: "足球集锦 - 98直播吧", link: currentUrl, language: "zh-CN", item: await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const detailResponse = await got_default({ method: "get", url: item.link, responseType: "buffer" }); const $detail = load(iconv.decode(detailResponse.data, "gbk")); const $body = $detail(".Content-body"); const matchTime = $body.find("div[style*=\"display:none\"]").text().match(/比赛时间:(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})/)?.[1]; $body.find("script, div[style*=\"display:none\"]").remove(); $body.contents().filter((_, node) => node.type === "comment").remove(); const $description = $detail("<div>"); if (matchTime) $description.append($detail("<p>").text(`比赛时间:${matchTime}`)); $description.append($body.html() ?? ""); return { ...item, description: $description.html() }; }))) }; } //#endregion export { route };