diff --git a/src/vehicle.handler.js b/src/vehicle.handler.js index 5b1d94a6af7bf0c6213da61adc1f788f78edb3bd..94b63ef85406d39f649edf49e464bf376c80c75f 100644 --- a/src/vehicle.handler.js +++ b/src/vehicle.handler.js @@ -14,8 +14,8 @@ export const vehicleHandler = async ($, url, kvs, ds, locationURL, statisticServ return $(this).html().includes("'vehicleMake'"); }); - if (!scriptTag) { - log.info('Error', { text: 'No Script tag' }); + if (!scriptTag || !scriptTag.length) { + log.info('Error', { text: 'No matching script tag found' }); return; } let objectContent = scriptTag.html().match(/\{([^}]*)}/)[1]; @@ -41,12 +41,6 @@ export const vehicleHandler = async ($, url, kvs, ds, locationURL, statisticServ const price = initialData.vehiclePrice; - // keep this just in case - // const priceText = $('.vdetails-price') - // .text() - // .trim(); - // const price = priceText.match(/£([\d,]+)/)[1].replace(/,/g, ''); - const stringifier = new Stringifier(''); // Ignore cars without prices, price is required criteria