rsshub
Version:
Make RSS Great Again!
56 lines (55 loc) • 1.81 kB
JavaScript
import { t as parseDate } from "./parse-date-Cr0wQjV_.mjs";
import { t as cache_default } from "./cache-BkqOokyU.mjs";
import { t as got_default } from "./got-BTowW50G.mjs";
import { t as timezone } from "./timezone-BBvDwS_3.mjs";
import { load } from "cheerio";
//#region lib/routes/guanhai/index.ts
const route = {
path: "/",
categories: ["new-media"],
example: "/guanhai",
radar: [{
source: ["guanhai.com.cn/"],
target: ""
}],
name: "首页",
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) => {
const $item = $(item);
return {
title: $item.attr("title"),
link: $item.attr("href")
};
});
const list = [...$(".pic-summary .title").toArray().map((item) => {
const $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 ??= 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 };