UNPKG

rsshub

Version:
61 lines (59 loc) 1.96 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import "./helpers-DxBp0Pty.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { t as timezone } from "./timezone-D8cuwzTY.mjs"; import { load } from "cheerio"; //#region lib/routes/guanhai/index.ts const route = { path: "/", radar: [{ source: ["guanhai.com.cn/"], target: "" }], name: "Unknown", maintainers: ["TonyRL"], handler, url: "guanhai.com.cn/" }; async function handler() { const { data: response } = await got_default("https://www.guanhai.com.cn"); const $ = load(response); const recommand = $(".img-box ul > a").toArray().map((item) => { item = $(item); return { title: item.attr("title"), link: item.attr("href") }; }); const list = [...$(".pic-summary .title").toArray().map((item) => { item = $(item); return { title: item.find("a").attr("title"), link: item.find("a").attr("href"), pubDate: timezone(parseDate(item.find("time").text(), "YYYY-MM-DD HH:mm"), 8) }; }), ...recommand].filter((item) => item.link.startsWith("http")); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const { data: response$1 } = await got_default(item.link); const $$1 = load(response$1); item.author = $$1(".source").text(); item.description = $$1(".article-content").html() ?? $$1(".video-content").html(); item.pubDate = item.pubDate ?? timezone(parseDate($$1(".date").text(), "YYYY-MM-DD HH:mm"), 8); return item; }))); return { title: $("head title").text(), description: $("head meta[name=description]").text(), image: "https://www.guanhai.com.cn/favicon.ico", link: "https://www.guanhai.com.cn", item: items }; } //#endregion export { route };