rsshub
Version:
Make RSS Great Again!
53 lines (51 loc) • 1.73 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 { r as getSubPath } from "./common-utils-Cz5bFBus.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/dgjyw/index.ts
const route = {
path: "*",
name: "Unknown",
maintainers: [],
handler
};
async function handler(ctx) {
const params = getSubPath(ctx);
const rootUrl = "https://www.dgjyw.com";
const currentUrl = `${rootUrl}${params === "/" ? "/tz" : params}.htm`;
const $ = load((await got_default(currentUrl)).data);
let items = $("div.text-list ul li a").toArray().map((item) => {
item = $(item);
const link = item.attr("href");
return {
title: item.text(),
link: `${link.startsWith("http") ? "" : `${rootUrl}/`}${link}`,
pubDate: parseDate(item.next().text())
};
});
items = await Promise.all(items.map((item) => cache_default.tryGet(item.link, async () => {
if (/dgjyw\.com/.test(item.link)) {
const content = load((await got_default(item.link)).data);
content(".cont-tit").remove();
content(".art-body").html(content(".v_news_content").html());
item.pubDate = timezone(parseDate(content("meta[name=\"PubDate\"]").attr("content")), 8);
item.description = content("form[name=\"_newscontent_fromname\"]").html();
}
return item;
})));
return {
title: $("title").text(),
link: currentUrl,
item: items
};
}
//#endregion
export { route };