mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
fixing kalaydo provider
This commit is contained in:
@@ -8,8 +8,8 @@ function normalize(o) {
|
|||||||
.split('/')
|
.split('/')
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.reverse()[0];
|
.reverse()[0];
|
||||||
const price = o.price.replace('Preis: ', '');
|
const price = o.price == null ? 'unknown' : o.price.trim().replace('Preis', '');
|
||||||
let size = o.size.replace('Wohnfläche: ', '').replace('ca. ', '');
|
let size = o.size == null ? 'unknown' : o.size.replace('Wohnfläche: ', '').replace('ca. ', '');
|
||||||
size += ' / ' + o.rooms;
|
size += ' / ' + o.rooms;
|
||||||
const address = '---';
|
const address = '---';
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ function applyBlacklist(o) {
|
|||||||
const descNotBlacklisted = !utils.isOneOf(o.description, appliedBlackList);
|
const descNotBlacklisted = !utils.isOneOf(o.description, appliedBlackList);
|
||||||
|
|
||||||
const isBlacklistedDistrict =
|
const isBlacklistedDistrict =
|
||||||
appliedBlacklistedDistricts.length === 0 ? false : utils.isOneOf(o.title, appliedBlacklistedDistricts);
|
appliedBlacklistedDistricts.length === 0 ? false : utils.isOneOf(o.title, appliedBlacklistedDistricts);
|
||||||
|
|
||||||
return !isBlacklistedDistrict && titleNotBlacklisted && descNotBlacklisted;
|
return !isBlacklistedDistrict && titleNotBlacklisted && descNotBlacklisted;
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,7 @@ const config = {
|
|||||||
crawlContainer: '#resultList .resultitem-content-container',
|
crawlContainer: '#resultList .resultitem-content-container',
|
||||||
crawlFields: {
|
crawlFields: {
|
||||||
id: '.resultitem-content-container a@href',
|
id: '.resultitem-content-container a@href',
|
||||||
price: '.clear-row .rent | removeNewline | trim',
|
price: '.description .rent | removeNewline | trim',
|
||||||
title: '.resultitem-content-container a@title',
|
title: '.resultitem-content-container a@title',
|
||||||
link: '.resultitem-content-container a@href',
|
link: '.resultitem-content-container a@href',
|
||||||
rooms: '.resultitem-content-container .no-of-rooms | removeNewline | trim',
|
rooms: '.resultitem-content-container .no-of-rooms | removeNewline | trim',
|
||||||
@@ -44,14 +44,13 @@ const config = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.init = (sourceConfig, blacklist, blacklistedDistricts) => {
|
exports.init = (sourceConfig, blacklist, blacklistedDistricts) => {
|
||||||
config.enabled = sourceConfig.enabled;
|
config.enabled = sourceConfig.enabled;
|
||||||
config.url = sourceConfig.url;
|
config.url = sourceConfig.url;
|
||||||
appliedBlackList = blacklist;
|
appliedBlackList = blacklist;
|
||||||
appliedBlacklistedDistricts = blacklistedDistricts;
|
appliedBlacklistedDistricts = blacklistedDistricts;
|
||||||
};
|
};
|
||||||
|
|
||||||
//must match the id of the source given in the config!
|
//must match the id of the source given in the config!
|
||||||
exports.id = () => 'kalaydo';
|
exports.id = () => 'kalaydo';
|
||||||
|
|
||||||
exports.config = config;
|
exports.config = config;
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ describe('#kalaydo testsuite()', () => {
|
|||||||
'./notification/notify': mockNotification
|
'./notification/notify': mockNotification
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should test kalaydo provider', async () => {
|
it.only('should test kalaydo provider', async () => {
|
||||||
return await new Promise(resolve => {
|
return await new Promise(resolve => {
|
||||||
const fredy = new Fredy(provider.config, null, provider.id(), 'test1');
|
const fredy = new Fredy(provider.config, null, provider.id(), 'test1');
|
||||||
fredy.execute().then(() => {
|
fredy.execute().then(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user