mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
* init map view * switching off 3d buildings when sattelite view is on * rename menu items * upgrading dependencies, adding provider to popups * adding screenshot for map view * fixing readme * next release version
68 lines
2.0 KiB
JavaScript
68 lines
2.0 KiB
JavaScript
/*
|
|
* Copyright (c) 2026 by Christian Kellner.
|
|
* Licensed under Apache-2.0 with Commons Clause and Attribution/Naming Clause
|
|
*/
|
|
|
|
import { buildHash, isOneOf } from '../utils.js';
|
|
import checkIfListingIsActive from '../services/listings/listingActiveTester.js';
|
|
|
|
let appliedBlackList = [];
|
|
|
|
function shortenLink(link) {
|
|
return link.substring(0, link.indexOf('?'));
|
|
}
|
|
|
|
function parseId(shortenedLink) {
|
|
return shortenedLink.substring(shortenedLink.lastIndexOf('/') + 1);
|
|
}
|
|
|
|
function normalize(o) {
|
|
const baseUrl = 'https://www.immobilien.de';
|
|
const size = o.size || null;
|
|
const price = o.price || null;
|
|
const title = o.title || 'No title available';
|
|
const address = o.address || null;
|
|
const shortLink = shortenLink(o.link);
|
|
const link = `${baseUrl}/${shortLink}`;
|
|
const image = baseUrl + o.image;
|
|
const id = buildHash(parseId(shortLink), o.price);
|
|
return Object.assign(o, { id, price, size, title, address, link, image });
|
|
}
|
|
|
|
function applyBlacklist(o) {
|
|
const titleNotBlacklisted = !isOneOf(o.title, appliedBlackList);
|
|
const descNotBlacklisted = !isOneOf(o.description, appliedBlackList);
|
|
return titleNotBlacklisted && descNotBlacklisted;
|
|
}
|
|
|
|
const config = {
|
|
url: null,
|
|
crawlContainer: '._ref',
|
|
sortByDateParam: 'sort_col=*created_ts&sort_dir=desc',
|
|
waitForSelector: 'body',
|
|
crawlFields: {
|
|
id: '@href', //will be transformed later
|
|
price: '.list_entry .immo_preis .label_info',
|
|
size: '.list_entry .flaeche .label_info | removeNewline | trim',
|
|
title: '.list_entry .part_text h3 span',
|
|
description: '.list_entry .description | trim',
|
|
link: '@href',
|
|
address: '.list_entry .place',
|
|
image: '.list_entry img@src',
|
|
},
|
|
normalize: normalize,
|
|
filter: applyBlacklist,
|
|
activeTester: checkIfListingIsActive,
|
|
};
|
|
export const init = (sourceConfig, blacklist) => {
|
|
config.enabled = sourceConfig.enabled;
|
|
config.url = sourceConfig.url;
|
|
appliedBlackList = blacklist || [];
|
|
};
|
|
export const metaInformation = {
|
|
name: 'Immobilien.de',
|
|
baseUrl: 'https://www.immobilien.de/',
|
|
id: 'immobilienDe',
|
|
};
|
|
export { config };
|