2023-03-13 13:42:43 +01:00
|
|
|
import utils from '../utils.js';
|
2021-05-11 11:25:14 +02:00
|
|
|
let appliedBlackList = [];
|
2021-11-11 15:31:53 +01:00
|
|
|
function nullOrEmpty(val) {
|
|
|
|
|
return val == null || val.length === 0;
|
|
|
|
|
}
|
2021-05-11 11:25:14 +02:00
|
|
|
function normalize(o) {
|
2021-11-11 15:31:53 +01:00
|
|
|
const title = nullOrEmpty(o.title) ? 'NO TITLE FOUND' : o.title.replace('NEU', '');
|
|
|
|
|
const address = nullOrEmpty(o.address) ? 'NO ADDRESS FOUND' : (o.address || '').replace(/\(.*\),.*$/, '').trim();
|
2024-02-08 10:36:47 +01:00
|
|
|
const link = nullOrEmpty(o.address) ? 'NO LINK' : `https://www.immobilienscout24.de${o.link.substring(o.link.indexOf('/expose'))}`;
|
2021-05-11 11:25:14 +02:00
|
|
|
return Object.assign(o, { title, address, link });
|
|
|
|
|
}
|
|
|
|
|
function applyBlacklist(o) {
|
|
|
|
|
return !utils.isOneOf(o.title, appliedBlackList);
|
|
|
|
|
}
|
|
|
|
|
const config = {
|
|
|
|
|
url: null,
|
|
|
|
|
crawlContainer: '#resultListItems li.result-list__listing',
|
2021-11-26 21:02:09 +01:00
|
|
|
sortByDateParam: 'sorting=2',
|
2021-05-11 11:25:14 +02:00
|
|
|
crawlFields: {
|
|
|
|
|
id: '.result-list-entry@data-obid | int',
|
|
|
|
|
price: '.result-list-entry .result-list-entry__criteria .grid-item:first-child dd | removeNewline | trim',
|
|
|
|
|
size: '.result-list-entry .result-list-entry__criteria .grid-item:nth-child(2) dd | removeNewline | trim',
|
2024-01-26 19:33:45 +01:00
|
|
|
title: '.result-list-entry .result-list-entry__brand-title-container h2 | removeNewline | trim',
|
2021-05-11 11:25:14 +02:00
|
|
|
link: '.result-list-entry .result-list-entry__brand-title-container@href',
|
|
|
|
|
address: '.result-list-entry .result-list-entry__map-link',
|
|
|
|
|
},
|
|
|
|
|
paginate: '#pager .align-right a@href',
|
|
|
|
|
normalize: normalize,
|
|
|
|
|
filter: applyBlacklist,
|
|
|
|
|
};
|
2023-03-13 13:42:43 +01:00
|
|
|
export const init = (sourceConfig, blacklist) => {
|
2021-05-11 11:25:14 +02:00
|
|
|
config.enabled = sourceConfig.enabled;
|
|
|
|
|
config.url = sourceConfig.url;
|
|
|
|
|
appliedBlackList = blacklist || [];
|
|
|
|
|
};
|
2023-03-13 13:42:43 +01:00
|
|
|
export const metaInformation = {
|
2021-05-11 11:25:14 +02:00
|
|
|
name: 'Immoscout',
|
|
|
|
|
baseUrl: 'https://www.immobilienscout24.de/',
|
2023-03-13 13:42:43 +01:00
|
|
|
id: 'immoscout',
|
2021-05-11 11:25:14 +02:00
|
|
|
};
|
2023-03-13 13:42:43 +01:00
|
|
|
export { config };
|