fixing immowelt crawler

This commit is contained in:
Christian Kellner
2018-06-10 10:50:45 +02:00
parent bb08d036af
commit acdbfd54cf
2 changed files with 6 additions and 5 deletions

View File

@@ -3,7 +3,7 @@ const config = require('../../conf/config.json');
const utils = require('../utils'); const utils = require('../utils');
function normalize(o) { function normalize(o) {
const size = o.size.split('Wohnfläche')[0]; const size = o.size.split('Wohnfläche')[1].replace(' (ca.) ', '');
const address = o.address; const address = o.address;
return Object.assign(o, { size, address }); return Object.assign(o, { size, address });
@@ -24,11 +24,10 @@ const immowelt = {
crawlFields: { crawlFields: {
id: '@data-estateid | int', id: '@data-estateid | int',
price: '.hardfacts_3 strong | removeNewline | trim', price: '.hardfacts_3 strong | removeNewline | trim',
size: '.hardfacts_3 div:nth-child(2):not(.hardfactlabel)| removeNewline | trim', size: '.js-object.listitem_wrap .hardfacts_3 div:nth-child(2)| removeNewline | trim',
title: '.listcontent.clear h2', title: '.listcontent.clear h2',
link: 'a@href', link: 'a@href',
description: '.listconten_offset .listmerkmale| removeNewline | trim', address: '.listcontent .details .listlocation| removeNewline | trim'
address: '.listconten_offset .listlocation| removeNewline | trim'
}, },
paginate: '#pnlPaging #nlbPlus@href', paginate: '#pnlPaging #nlbPlus@href',
normalize: normalize, normalize: normalize,

View File

@@ -41,7 +41,9 @@ describe('#immowelt testsuite()', () => {
immoweltDbContent.immowelt[idx] immoweltDbContent.immowelt[idx]
); );
expect(notify.price).that.does.include('€'); expect(notify.price).that.does.include('€');
expect(notify.size).that.does.include('m²'); if(notify.size.trim().toLowerCase() !== 'k.a.') {
expect(notify.size).that.does.include('m²');
}
expect(notify.title).to.be.not.empty; expect(notify.title).to.be.not.empty;
expect(notify.link).that.does.include('https://www.immowelt.de'); expect(notify.link).that.does.include('https://www.immowelt.de');
expect(notify.address).to.be.not.empty; expect(notify.address).to.be.not.empty;