UNPKG

rsshub

Version:
56 lines (55 loc) 2.18 kB
import { t as rofetch } from "./ofetch-C3ts-Hud.mjs"; import { load } from "cheerio"; //#region lib/routes/oesw/index.ts const FEED_LANGUAGE = "de"; const FEED_LOGO = "https://www.oesw.at/fileadmin/Logos/OeSW_AG/OeSW-Logo2024-RGB.png"; const SITE_URL = "https://www.oesw.at"; const BASE_URL = `${SITE_URL}/immobilienangebot/`; const route = { name: "Immobilienangebot", example: "/oesw/sofort-verfuegbar/objectType=1&financingType=2&region=1020", path: "/:path{.+}?", parameters: { path: "Listing page (`immobiliensuche` by default), optionally followed by the query parameters, see the description below" }, maintainers: ["sk22"], categories: ["other"], description: `Get your parameters on ${SITE_URL} under "Immobilienangebot". Make sure to remove the \`?\` at the beginning from the query parameters!`, async handler(ctx) { const parts = (ctx.req.param("path") ?? "").split("/"); const listingPage = parts[0] || "immobiliensuche"; let params = parts[1] || ""; if (params.startsWith("&")) params = params.slice(1); const link = `${BASE_URL}${listingPage}.html?${params}`; const $ = load(await rofetch(link)); const title = $("title").text(); const items = $("li[data-objlist-url] > a").toArray().map((el) => { const count = $(el).find(".boardPic > .count").text().trim(); const category = $(el).find(".boardPic > .label").toArray().map((l) => $(l).text().trim()).filter((l) => l.length); const titles = [el.attribs["data-title2"].trim(), el.attribs["data-title"].trim()].filter((t) => t.length); const imageSrc = el.attribs["data-largesrc"]; const image = imageSrc.startsWith("/") ? SITE_URL + imageSrc : imageSrc; return { guid: el.attribs.href + (count ? `#count-${count}` : ""), title: (count ? `(${count}) ` : "") + titles.join(", "), link: el.attribs.href, description: el.attribs["data-description"], category, image, content: { html: el.attribs["data-description-long"], text: el.attribs["data-description-long"] } }; }); return { title, language: FEED_LANGUAGE, logo: FEED_LOGO, allowEmpty: true, item: items, link }; } }; //#endregion export { route };