mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
* Fredy now supports pulling the main Image from the listing and send it together with the usual information
52 lines
1.8 KiB
JavaScript
Executable File
52 lines
1.8 KiB
JavaScript
Executable File
import utils, { buildHash } from '../utils.js';
|
|
|
|
let appliedBlackList = [];
|
|
let appliedBlacklistedDistricts = [];
|
|
|
|
function normalize(o) {
|
|
const size = o.size || '--- m²';
|
|
const id = buildHash(o.id, o.price);
|
|
const link = `https://www.kleinanzeigen.de${o.link}`;
|
|
return Object.assign(o, { id, size, link });
|
|
}
|
|
|
|
function applyBlacklist(o) {
|
|
const titleNotBlacklisted = !utils.isOneOf(o.title, appliedBlackList);
|
|
const descNotBlacklisted = !utils.isOneOf(o.description, appliedBlackList);
|
|
const isBlacklistedDistrict =
|
|
appliedBlacklistedDistricts.length === 0 ? false : utils.isOneOf(o.description, appliedBlacklistedDistricts);
|
|
return o.title != null && !isBlacklistedDistrict && titleNotBlacklisted && descNotBlacklisted;
|
|
}
|
|
|
|
const config = {
|
|
url: null,
|
|
crawlContainer: '#srchrslt-adtable .ad-listitem ',
|
|
//sort by date is standard oO
|
|
sortByDateParam: null,
|
|
waitForSelector: 'body',
|
|
crawlFields: {
|
|
id: '.aditem@data-adid | int',
|
|
price: '.aditem-main--middle--price-shipping--price | removeNewline | trim',
|
|
size: '.aditem-main .text-module-end | removeNewline | trim',
|
|
title: '.aditem-main .text-module-begin a | removeNewline | trim',
|
|
link: '.aditem-main .text-module-begin a@href | removeNewline | trim',
|
|
description: '.aditem-main .aditem-main--middle--description | removeNewline | trim',
|
|
address: '.aditem-main--top--left | trim | removeNewline',
|
|
image: 'img@src',
|
|
},
|
|
normalize: normalize,
|
|
filter: applyBlacklist,
|
|
};
|
|
export const metaInformation = {
|
|
name: 'Ebay Kleinanzeigen',
|
|
baseUrl: 'https://www.kleinanzeigen.de/',
|
|
id: 'kleinanzeigen',
|
|
};
|
|
export const init = (sourceConfig, blacklist, blacklistedDistricts) => {
|
|
config.enabled = sourceConfig.enabled;
|
|
config.url = sourceConfig.url;
|
|
appliedBlacklistedDistricts = blacklistedDistricts || [];
|
|
appliedBlackList = blacklist || [];
|
|
};
|
|
export { config };
|