UNPKG

rsshub

Version:
73 lines (71 loc) 2.3 kB
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/verfghbw/press.ts const route = { path: "/press/:keyword?", categories: ["government"], example: "/verfghbw/press", parameters: { keyword: "Keyword" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["verfgh.baden-wuerttemberg.de/de/presse-und-service/pressemitteilungen/"], target: "/press" }], name: "Press releases", maintainers: ["quinn-dev"], handler, url: "verfgh.baden-wuerttemberg.de/de/presse-und-service/pressemitteilungen/" }; async function handler(ctx) { const keyword = ctx.req.param("keyword"); const rootUrl = "https://verfgh.baden-wuerttemberg.de"; let request = { url: `${rootUrl}/de/presse-und-service/pressemitteilungen/`, headers: { Referer: `${rootUrl}/de/presse-und-service/pressemitteilungen/` } }; request = keyword ? { method: "post", form: { "tx_bwlistheader_list[search][keywords]": keyword }, ...request } : { method: "get", ...request }; const data = (await got_default(request)).data; const $ = load(data); const list = $(".pressListItem").toArray().map((item) => { item = $(item); const title = item.find(".pressListItemTeaser > h3").text().trim(); const link = rootUrl + "/" + item.find(".link-download").attr("href"); item.find(".pressListItemTeaser > h3").replaceWith((_, e) => `<p>${$(e).html()}</p>`); item.find("a").each((_, e) => $(e).attr("href", rootUrl + "/" + $(e).attr("href"))); return { title, link, description: item.find(".pressListItemTeaser").html(), pubDate: parseDate(item.find(".pressListItemDate > span").text(), "DD.MM.YYYY") }; }); return { title: "Verfassungsgerichtshof Baden-Württemberg - Pressemitteilungen", link: request.url, description: "Pressemitteilungen des Verfassungsgerichtshof für das Land Baden-Württemberg", item: list }; } //#endregion export { route };