From 08ecb6545bfc0b26b4b4c9fb96a4650ef5a7ca5c Mon Sep 17 00:00:00 2001 From: Edward Peterson Date: Thu, 9 Mar 2023 22:54:17 -0500 Subject: [PATCH] added survivor-cars processor --- index.js | 7 ++++++- processors/survivor-cars.processor.js | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 processors/survivor-cars.processor.js diff --git a/index.js b/index.js index b8e85eb..f099ba5 100644 --- a/index.js +++ b/index.js @@ -80,6 +80,7 @@ async function run(url, processor) { const payloads = await Promise.all(galleryUrls.map(image => new Promise(async (resolve, reject) => { superagent.get(image.url).responseType('blob').then(function (response) { if (response.statusCode == 200) { + console.log('Resolving', image.url) return resolve({ response: { content: { @@ -89,9 +90,13 @@ async function run(url, processor) { } } }); + } else { + console.log("Invalid status code", response.statusCode, 'for', image.url); + resolve({}) + } - resolve({}) }).catch(error => { + console.error(error) resolve({}) }); }))) diff --git a/processors/survivor-cars.processor.js b/processors/survivor-cars.processor.js new file mode 100644 index 0000000..ae24724 --- /dev/null +++ b/processors/survivor-cars.processor.js @@ -0,0 +1,22 @@ +const genericVinParserFactory = require("./generic-vin-parser"); +module.exports = { + baseUrl: 'survivor-cars.com', + async execute(page) { + const gallerySelector = '.show-car-thumbs' + const imageSelector = '.show-car-thumbs > a'; + await page.waitForSelector(gallerySelector); + const images = await page.$$(imageSelector); + const sources = await Promise.all(images.map(async carouselItem => { + const src = await page.evaluate(el => el.getAttribute('href'), carouselItem); + console.log(src); + return { url: src }; + })); + return sources; + }, + parseVIN: async function(page) { + return null; + }, + parseMileage: async function (page) { + return null; + } +} \ No newline at end of file