mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
Release v1.0.0 🎉
This commit is contained in:
46
lib/provider/kalaydo.js
Executable file
46
lib/provider/kalaydo.js
Executable file
@@ -0,0 +1,46 @@
|
||||
const config = require('../../conf/config.json');
|
||||
const Fredy = require('../fredy');
|
||||
const utils = require('../utils');
|
||||
|
||||
function normalize(o) {
|
||||
const id = o.id
|
||||
.split('/')
|
||||
.filter(Boolean)
|
||||
.reverse()[0];
|
||||
const price = o.price.replace('Preis: ', '');
|
||||
let size = o.size.replace('Wohnfläche: ', '').replace('ca. ', '');
|
||||
size += ' / ' + o.rooms;
|
||||
const address = '---';
|
||||
|
||||
return Object.assign(o, { id, price, size, address });
|
||||
}
|
||||
|
||||
function applyBlacklist(o) {
|
||||
const titleNotBlacklisted = !utils.isOneOf(o.title, config.blacklist);
|
||||
const descNotBlacklisted = !utils.isOneOf(o.description, config.blacklist);
|
||||
|
||||
const isBlacklistedDistrict =
|
||||
config.blacklistedDistrics.length === 0 ? false : utils.isOneOf(o.title, config.blacklistedDistrics);
|
||||
|
||||
return !isBlacklistedDistrict && titleNotBlacklisted && descNotBlacklisted;
|
||||
}
|
||||
|
||||
const kalaydo = {
|
||||
name: 'kalaydo',
|
||||
enabled: config.sources.kalaydo.enabled,
|
||||
url: config.sources.kalaydo.url,
|
||||
crawlContainer: '#resultList .resultitem-content-container',
|
||||
crawlFields: {
|
||||
id: '.resultitem-content-container a@href',
|
||||
price: '.clear-row .rent | removeNewline | trim',
|
||||
title: '.resultitem-content-container a@title',
|
||||
link: '.resultitem-content-container a@href',
|
||||
rooms: '.resultitem-content-container .no-of-rooms | removeNewline | trim',
|
||||
size: '.resultitem-content-container .living-area | removeNewline | trim'
|
||||
},
|
||||
paginate: '.markt_pagination_pageLinkNext .markt_pagination_link@href',
|
||||
normalize: normalize,
|
||||
filter: applyBlacklist
|
||||
};
|
||||
|
||||
module.exports = new Fredy(kalaydo);
|
||||
Reference in New Issue
Block a user