2021-05-11 11:25:14 +02:00
|
|
|
const { metaInformation } = require('../provider/immoscout');
|
2022-03-25 11:19:17 +01:00
|
|
|
//to better configure re-capture chose a random proxy each time we do a call
|
2021-05-11 11:25:14 +02:00
|
|
|
const config = require('../../conf/config.json');
|
|
|
|
|
|
|
|
|
|
const isImmoscout = (id) => {
|
|
|
|
|
return id.toLowerCase() === metaInformation.id;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
exports.transformUrlForScrapingAnt = (url, id) => {
|
|
|
|
|
if (isImmoscout(id)) {
|
|
|
|
|
//only do calls to scrapingAnt when dealing with Immoscout
|
2022-06-13 08:10:30 +02:00
|
|
|
url = `https://api.scrapingant.com/v1/general?url=${encodeURIComponent(url)}&proxy_type=datacenter`;
|
2021-05-11 11:25:14 +02:00
|
|
|
}
|
|
|
|
|
return url;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
exports.isScrapingAntApiKeySet = () => {
|
|
|
|
|
return config.scrapingAnt != null && config.scrapingAnt.apiKey != null && config.scrapingAnt.apiKey.length > 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
exports.isImmoscout = isImmoscout;
|
2022-04-29 13:22:39 +02:00
|
|
|
|
|
|
|
|
exports.makeUrlResidential = (url) => {
|
|
|
|
|
return url.replace('datacenter', 'residential');
|
|
|
|
|
};
|