2023-03-13 13:42:43 +01:00
|
|
|
import { metaInformation } from '../provider/immoscout.js';
|
|
|
|
|
import { config } from '../utils.js';
|
2021-05-11 11:25:14 +02:00
|
|
|
const isImmoscout = (id) => {
|
|
|
|
|
return id.toLowerCase() === metaInformation.id;
|
|
|
|
|
};
|
2023-03-13 13:42:43 +01:00
|
|
|
export const transformUrlForScrapingAnt = (url, id) => {
|
2021-05-11 11:25:14 +02:00
|
|
|
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;
|
|
|
|
|
};
|
2023-03-13 13:42:43 +01:00
|
|
|
export const isScrapingAntApiKeySet = () => {
|
2021-05-11 11:25:14 +02:00
|
|
|
return config.scrapingAnt != null && config.scrapingAnt.apiKey != null && config.scrapingAnt.apiKey.length > 0;
|
|
|
|
|
};
|
2023-03-13 13:42:43 +01:00
|
|
|
export const makeUrlResidential = (url) => {
|
2022-04-29 13:22:39 +02:00
|
|
|
return url.replace('datacenter', 'residential');
|
|
|
|
|
};
|
2023-03-13 13:42:43 +01:00
|
|
|
export { isImmoscout };
|