rsshub
Version:
Make RSS Great Again!
45 lines (43 loc) • 1.16 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import "./ofetch-BIyrKU3Y.mjs";
import { t as parseDate } from "./parse-date-BrP7mxXf.mjs";
import "./helpers-DxBp0Pty.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import { load } from "cheerio";
//#region lib/routes/gov/gz/index.ts
const rootUrl = "https://www.gz.gov.cn";
const urlMap = {
gzyw: "gzyw",
jrtt: "jrtt",
tzgg: "tzgg",
zcjd: "zcjd/zcjd"
};
const route = {
path: "/gz/:channel/:category",
name: "Unknown",
maintainers: [],
handler
};
async function handler(ctx) {
const url = `${rootUrl}/${ctx.req.param("channel")}/${urlMap[ctx.req.param("category")]}/`;
const $ = load((await got_default(url)).data);
const items = $(".news_list li").toArray().map((item) => {
item = $(item);
const href = item.find("a").attr("href");
return {
title: item.find("a").attr("title"),
link: href,
pubDate: parseDate(item.find("span").text())
};
});
return {
title: `广州市人民政府 - ${$(".main_title").text()}`,
link: url,
item: items
};
}
//#endregion
export { route };