fixing kalaydo provider

This commit is contained in:
Christian Kellner
2020-03-15 16:10:49 +01:00
parent 4f9ea8108c
commit 200e3217a4
2 changed files with 9 additions and 10 deletions

View File

@@ -8,8 +8,8 @@ function normalize(o) {
.split('/')
.filter(Boolean)
.reverse()[0];
const price = o.price.replace('Preis: ', '');
let size = o.size.replace('Wohnfläche: ', '').replace('ca. ', '');
const price = o.price == null ? 'unknown' : o.price.trim().replace('Preis', '');
let size = o.size == null ? 'unknown' : o.size.replace('Wohnfläche: ', '').replace('ca. ', '');
size += ' / ' + o.rooms;
const address = '---';
@@ -21,7 +21,7 @@ function applyBlacklist(o) {
const descNotBlacklisted = !utils.isOneOf(o.description, appliedBlackList);
const isBlacklistedDistrict =
appliedBlacklistedDistricts.length === 0 ? false : utils.isOneOf(o.title, appliedBlacklistedDistricts);
appliedBlacklistedDistricts.length === 0 ? false : utils.isOneOf(o.title, appliedBlacklistedDistricts);
return !isBlacklistedDistrict && titleNotBlacklisted && descNotBlacklisted;
}
@@ -32,7 +32,7 @@ const config = {
crawlContainer: '#resultList .resultitem-content-container',
crawlFields: {
id: '.resultitem-content-container a@href',
price: '.clear-row .rent | removeNewline | trim',
price: '.description .rent | removeNewline | trim',
title: '.resultitem-content-container a@title',
link: '.resultitem-content-container a@href',
rooms: '.resultitem-content-container .no-of-rooms | removeNewline | trim',
@@ -44,14 +44,13 @@ const config = {
};
exports.init = (sourceConfig, blacklist, blacklistedDistricts) => {
config.enabled = sourceConfig.enabled;
config.url = sourceConfig.url;
appliedBlackList = blacklist;
appliedBlacklistedDistricts = blacklistedDistricts;
config.enabled = sourceConfig.enabled;
config.url = sourceConfig.url;
appliedBlackList = blacklist;
appliedBlacklistedDistricts = blacklistedDistricts;
};
//must match the id of the source given in the config!
exports.id = () => 'kalaydo';
exports.config = config;

View File

@@ -12,7 +12,7 @@ describe('#kalaydo testsuite()', () => {
'./notification/notify': mockNotification
});
it('should test kalaydo provider', async () => {
it.only('should test kalaydo provider', async () => {
return await new Promise(resolve => {
const fredy = new Fredy(provider.config, null, provider.id(), 'test1');
fredy.execute().then(() => {