feat(route): Add WBV-GPA Austrian communal housing search (#20544)

* feat(category): add housing category

* feat(route): Add WBV-GPA housing search

* fix(route/wbv-gpa): fix import

* fix(route/wbv-gpa): fix feed title

* Revert "feat(category): add housing category"

This reverts commit 953f59421717592dc5d8f2e0d8c42b5d54c77c72.

* feat(route/wbv-gpa): change category

---------

Co-authored-by: Samuel Kaiser <samuel.kaiser@timetoact.at>
This commit is contained in:
sk22 2025-11-25 18:53:31 +01:00 committed by GitHub
parent 36b6b34ffc
commit cbff05689a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 79 additions and 0 deletions

View File

@ -0,0 +1,71 @@
import { load } from 'cheerio';
import ofetch from '@/utils/ofetch';
import type { Data, DataItem, Route } from '@/types';
const FEED_LANGUAGE = 'de' as const;
const FEED_LOGO = 'https://www.wbv-gpa.at/app/uploads/2024/01/cropped-WBV-Favicon-192x192.png';
const SITE_URL = 'https://www.wbv-gpa.at' as const;
const BASE_URL = `${SITE_URL}/angebote/` as const;
export const route: Route = {
name: 'Angebote',
example: '/wbv-gpa/wohnungen/wien',
path: '/:category?/:state?',
maintainers: ['sk22'],
categories: ['other'],
description: `
Search housing by WBV-GPA, see "Angebote" menu item in https://www.wbv-gpa.at.
Filtering by state is done client-side.
`,
parameters: {
category: 'Anything behind `/angebote/` in the URL. Default: `wohnungen`',
state: 'Optionally filter by Austrian state (`wien`, `steiermark`, ...)',
},
radar: [
{
// wbv-gpa.at/wohnungen is equivalent to wbv-gpa.at/angebote/wohnungen
source: [`${SITE_URL}/wohnungen/`, `${BASE_URL}/:category`],
target: '/:category',
},
],
async handler(ctx) {
const category = ctx.req.param('category') || 'wohnungen';
const state = ctx.req.param('state');
const link = BASE_URL + category;
const response = await ofetch(link);
const $ = load(response);
const title = $('title').text();
const items = $('.objects__list__rows__item.mix')
.toArray()
.map((el) => {
const $el = $(el);
const link = $el.find('a').attr('href');
const title = $el
.find('.objects__list__rows__item__info__cell:not(.desktop_only):not(.objects__list__rows__item__info__cell--link)')
.toArray()
.map((el) => $(el).text().trim())
.join(', ');
const description = $el
.find('.objects__list__rows__item__info__cell.desktop_only:not(.objects__list__rows__item__info__cell--link)')
.toArray()
.map((el) => $(el).text().trim())
.join(', ');
// no pubDate and no image :(
return state && !$el.hasClass(state) ? false : ({ title, description, link } satisfies DataItem);
})
.filter((item) => item !== false);
return {
title,
language: FEED_LANGUAGE,
logo: FEED_LOGO,
allowEmpty: true,
item: items,
link,
} satisfies Data;
},
};

View File

@ -0,0 +1,8 @@
import type { Namespace } from '@/types';
export const namespace: Namespace = {
name: 'WBV-GPA',
description: 'Wohnbauvereinigung für Privatangestellte - Gemeinnützige Gesellschaft mit beschränkter Haftung',
url: 'wbv-gpa.at',
lang: 'de',
};