2018-01-25 16:38:39 +01:00
|
|
|
const utils = require('../utils');
|
|
|
|
|
|
2020-02-26 09:05:20 +01:00
|
|
|
let appliedBlackList = [];
|
|
|
|
|
|
2018-01-25 16:38:39 +01:00
|
|
|
function normalize(o) {
|
2020-02-16 13:09:15 +01:00
|
|
|
let size = `${o.size.replace(' Wohnfläche ', '').trim()}`;
|
2020-02-26 09:05:20 +01:00
|
|
|
if (o.rooms != null) {
|
|
|
|
|
size += ` / / ${o.rooms.trim()}`;
|
2020-02-16 13:09:15 +01:00
|
|
|
}
|
2018-01-25 16:51:05 +01:00
|
|
|
const link = `https://www.1a-immobilienmarkt.de/expose/${o.id}.html`;
|
2018-01-25 16:38:39 +01:00
|
|
|
|
|
|
|
|
return Object.assign(o, { size, link });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function applyBlacklist(o) {
|
2020-02-26 09:05:20 +01:00
|
|
|
const titleNotBlacklisted = !utils.isOneOf(o.title, appliedBlackList);
|
|
|
|
|
const descNotBlacklisted = !utils.isOneOf(o.description, appliedBlackList);
|
2018-01-25 16:38:39 +01:00
|
|
|
|
|
|
|
|
return titleNotBlacklisted && descNotBlacklisted;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-26 09:05:20 +01:00
|
|
|
const config = {
|
|
|
|
|
enabled: null,
|
|
|
|
|
url: null,
|
2018-01-25 16:38:39 +01:00
|
|
|
crawlContainer: '.tabelle',
|
|
|
|
|
crawlFields: {
|
|
|
|
|
id: '.inner_object_data input[name="marker_objekt_id"]@value | int',
|
|
|
|
|
price: '.tabelle .inner_object_data .single_data_price | removeNewline | trim',
|
|
|
|
|
size: '.tabelle .inner_object_data .data_boxes div:nth-child(1)',
|
|
|
|
|
rooms: '.tabelle .inner_object_data .data_boxes div:nth-child(2)',
|
|
|
|
|
title: '.tabelle .inner_object_data .tabelle_inhalt_titel_black | removeNewline | trim',
|
|
|
|
|
description: '.tabelle .inner_object_data .objekt_beschreibung | removeNewline | trim'
|
|
|
|
|
},
|
|
|
|
|
paginate: '.pagination_blocks div:last a@href',
|
|
|
|
|
normalize: normalize,
|
|
|
|
|
filter: applyBlacklist
|
|
|
|
|
};
|
|
|
|
|
|
2020-02-26 09:05:20 +01:00
|
|
|
exports.init = (sourceConfig, blacklist) => {
|
|
|
|
|
config.enabled = sourceConfig.enabled;
|
|
|
|
|
config.url = sourceConfig.url;
|
|
|
|
|
appliedBlackList = blacklist;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//must match the id of the source given in the config!
|
|
|
|
|
exports.id = () => 'einsAImmobilien';
|
|
|
|
|
|
|
|
|
|
exports.config = config;
|