rsshub
Version:
Make RSS Great Again!
43 lines (41 loc) • 1.5 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 "./timezone-CA9Huotp.mjs";
import { n as processItems, r as rootUrl, t as fetchData } from "./util-B_U-6JFE.mjs";
import { load } from "cheerio";
//#region lib/routes/gov/chinamine-safety/zfxxgk.ts
const route = {
path: "/chinamine-safety/zfxxgk/:category{.+}?",
name: "Unknown",
maintainers: [],
handler
};
async function handler(ctx) {
const { category = "fdzdgknr/tzgg" } = ctx.req.param();
const limit = ctx.req.query("limit") ? Number.parseInt(ctx.req.query("limit"), 10) : 30;
const currentUrl = new URL(`zfxxgk/${category.endsWith("/") ? category : `${category}/`}`, rootUrl).href;
const { data: response } = await got_default(currentUrl);
const $ = load(response);
let items = $("ul#ogi-list li a, div#ogi-list dd a").slice(0, limit).toArray().map((item) => {
item = $(item);
return {
title: item.contents().first().text(),
link: new URL(item.prop("href"), currentUrl).href,
pubDate: parseDate(item.parent().find("span").text())
};
});
items = await processItems(items, cache_default.tryGet);
return {
item: items,
...fetchData($, currentUrl)
};
}
//#endregion
export { route };