2025-09-22 09:57:50 +02:00
|
|
|
import { isOneOf, buildHash } from '../utils.js';
|
|
|
|
|
import checkIfListingIsActive from '../services/listings/listingActiveTester.js';
|
2024-09-05 13:34:14 +02:00
|
|
|
|
2020-02-26 09:05:20 +01:00
|
|
|
let appliedBlackList = [];
|
2024-09-05 13:34:14 +02:00
|
|
|
|
2024-07-24 09:32:21 +02:00
|
|
|
function nullOrEmpty(val) {
|
2025-07-23 08:47:26 +02:00
|
|
|
return val == null || val.length === 0;
|
2024-07-24 09:32:21 +02:00
|
|
|
}
|
2024-09-05 13:34:14 +02:00
|
|
|
|
2018-02-13 12:43:37 +01:00
|
|
|
function normalize(o) {
|
2025-07-23 08:47:26 +02:00
|
|
|
const link = nullOrEmpty(o.link)
|
|
|
|
|
? 'NO LINK'
|
|
|
|
|
: `https://www.neubaukompass.de${o.link.substring(o.link.indexOf('/neubau'))}`;
|
|
|
|
|
const id = buildHash(o.link, o.price);
|
|
|
|
|
return Object.assign(o, { id, link });
|
2018-02-13 12:43:37 +01:00
|
|
|
}
|
2024-09-05 13:34:14 +02:00
|
|
|
|
2018-02-13 12:43:37 +01:00
|
|
|
function applyBlacklist(o) {
|
2025-09-22 09:57:50 +02:00
|
|
|
return !isOneOf(o.title, appliedBlackList);
|
2018-02-13 12:43:37 +01:00
|
|
|
}
|
2024-09-05 13:34:14 +02:00
|
|
|
|
2020-02-26 09:05:20 +01:00
|
|
|
const config = {
|
2025-07-23 08:47:26 +02:00
|
|
|
url: null,
|
|
|
|
|
crawlContainer: '.col-12.mb-4',
|
|
|
|
|
sortByDateParam: 'Sortierung=Id&Richtung=DESC',
|
2025-09-22 20:53:00 +02:00
|
|
|
waitForSelector: 'div[data-live-name-value="SearchList"]',
|
2025-07-23 08:47:26 +02:00
|
|
|
crawlFields: {
|
|
|
|
|
id: 'a@href',
|
|
|
|
|
title: 'a@title | removeNewline | trim',
|
|
|
|
|
link: 'a@href',
|
|
|
|
|
address: '.nbk-project-card__description | removeNewline | trim',
|
|
|
|
|
price: '.nbk-project-card__spec-item .nbk-project-card__spec-value | removeNewline | trim',
|
2025-08-30 21:21:34 +02:00
|
|
|
image: '.nbk-project-card__image@src',
|
2025-07-23 08:47:26 +02:00
|
|
|
},
|
|
|
|
|
normalize: normalize,
|
|
|
|
|
filter: applyBlacklist,
|
2025-09-22 09:57:50 +02:00
|
|
|
activeTester: checkIfListingIsActive,
|
2018-02-13 12:43:37 +01:00
|
|
|
};
|
2023-03-13 13:42:43 +01:00
|
|
|
export const init = (sourceConfig, blacklist) => {
|
2025-07-23 08:47:26 +02:00
|
|
|
config.enabled = sourceConfig.enabled;
|
|
|
|
|
config.url = sourceConfig.url;
|
|
|
|
|
appliedBlackList = blacklist || [];
|
2020-02-26 09:05:20 +01:00
|
|
|
};
|
2023-03-13 13:42:43 +01:00
|
|
|
export const metaInformation = {
|
2025-07-23 08:47:26 +02:00
|
|
|
name: 'Neubau Kompass',
|
|
|
|
|
baseUrl: 'https://www.neubaukompass.de/',
|
|
|
|
|
id: 'neubauKompass',
|
2021-01-21 16:09:23 +01:00
|
|
|
};
|
2025-07-23 08:47:26 +02:00
|
|
|
export { config };
|