rsshub
Version:
Make RSS Great Again!
61 lines (59 loc) • 1.95 kB
JavaScript
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 { t as timezone } from "./timezone-CA9Huotp.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 } = await got_default(item.link);
const $ = load(response);
item.author = $(".source").text();
item.description = $(".article-content").html() ?? $(".video-content").html();
item.pubDate = item.pubDate ?? timezone(parseDate($(".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 };