rsshub
Version:
Make RSS Great Again!
48 lines (46 loc) • 1.61 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 { load } from "cheerio";
//#region lib/routes/keepass/news.ts
const route = {
path: "/",
name: "Unknown",
maintainers: ["TonyRL"],
handler
};
async function handler(ctx) {
const baseUrl = "https://keepass.info/news/news_all.html";
const { data: response } = await got_default(baseUrl);
const $ = load(response);
const list = $("p > a").toArray().map((elem) => {
elem = $(elem);
return {
title: elem.find("b").text(),
link: new URL(elem.attr("href"), baseUrl).href,
pubDate: parseDate(elem.next().next("small").text().split(".")[0])
};
}).slice(0, ctx.req.query("limit") ? Number.parseInt(ctx.req.query("limit"), 10) : 10);
const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
if (!item.link.startsWith("https://keepass.info/")) return item;
const { data } = await got_default(item.link);
const $ = load(data);
$(".sectionheader").remove();
$(".laytablews > tbody> tr:nth-child(1) > td:nth-child(2) > p").first().remove();
item.description = $(".laytablews > tbody> tr:nth-child(1) > td:nth-child(2)").html();
return item;
})));
return {
title: $("head title").attr("content"),
link: baseUrl,
item: items
};
}
//#endregion
export { route };