mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-10-24 23:42:40 +08:00
feat(route): Add route for oesw.at (#20537)
* feat(category): add housing category * feat(route): add oesw.at housing search * fix(route/oesw): append count to guid instead of link * fix(route/oesw): fix feed title and imports * Revert "feat(category): add housing category" This reverts commit 953f59421717592dc5d8f2e0d8c42b5d54c77c72. * feat(route/oesw): change category --------- Co-authored-by: Samuel Kaiser <samuel.kaiser@timetoact.at>
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
import { load } from 'cheerio';
|
||||
import { getSubPath } from '@/utils/common-utils';
|
||||
import ofetch from '@/utils/ofetch';
|
||||
import type { Data, DataItem, Route } from '@/types';
|
||||
|
||||
const FEED_LANGUAGE = 'de' as const;
|
||||
const FEED_LOGO = 'https://www.oesw.at/fileadmin/Logos/OeSW_AG/OeSW-Logo2024-RGB.png';
|
||||
const SITE_URL = 'https://www.oesw.at' as const;
|
||||
const BASE_URL = `${SITE_URL}/immobilienangebot/` as const;
|
||||
|
||||
export const route: Route = {
|
||||
name: 'Immobilienangebot',
|
||||
example: '/oesw/sofort-verfuegbar/objectType=1&financingType=2®ion=1020',
|
||||
path: '*',
|
||||
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) {
|
||||
// ['', 'sofort-verfuegbar', 'objectType=1®ion=1010']
|
||||
const parts = getSubPath(ctx).split('/');
|
||||
const listingPage = parts[1] || 'immobiliensuche';
|
||||
let params = parts[2] || '';
|
||||
if (params.startsWith('&')) {
|
||||
params = params.slice(1);
|
||||
}
|
||||
|
||||
const link = `${BASE_URL}${listingPage}.html?${params}`;
|
||||
const response = await ofetch(link);
|
||||
const $ = load(response);
|
||||
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 {
|
||||
// add count to identifier so that rss readers display a new item
|
||||
// when only the count (i.e. available rentals) gets changed
|
||||
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'] },
|
||||
// no pubDate :(
|
||||
} satisfies DataItem;
|
||||
});
|
||||
|
||||
return {
|
||||
title,
|
||||
language: FEED_LANGUAGE,
|
||||
logo: FEED_LOGO,
|
||||
allowEmpty: true,
|
||||
item: items,
|
||||
link,
|
||||
} satisfies Data;
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
import { Namespace } from '@/types';
|
||||
|
||||
export const namespace: Namespace = {
|
||||
name: 'ÖSW',
|
||||
url: 'oesw.at',
|
||||
description: 'Österreichisches Siedlungswerk - Gemeinnützige Wohnungsaktiengesellschaft',
|
||||
};
|
||||
Reference in New Issue
Block a user