News Feed Forums General Web Scraping How can I scrape car rental details from Turo.com using JavaScript?

  • How can I scrape car rental details from Turo.com using JavaScript?

    Posted by Fiachna Iyabo on 12/20/2024 at 10:02 am

    Scraping car rental details from Turo.com using JavaScript can help gather information like vehicle names, daily prices, and rental locations. Using Node.js with Puppeteer, you can automate browser interactions to handle dynamic content and extract the necessary data. Below is an example script for scraping car rentals from Turo.

    const puppeteer = require('puppeteer');
    (async () => {
        const browser = await puppeteer.launch({ headless: true });
        const page = await browser.newPage();
        const url = 'https://www.turo.com/us/en/car-rentals';
        await page.goto(url, { waitUntil: 'networkidle2' });
        const cars = await page.evaluate(() => {
            const carList = [];
            const items = document.querySelectorAll('.vehicle-card');
            items.forEach(item => {
                const name = item.querySelector('.vehicle-title')?.textContent.trim() || 'Name not available';
                const price = item.querySelector('.price')?.textContent.trim() || 'Price not available';
                const location = item.querySelector('.location')?.textContent.trim() || 'Location not available';
                carList.push({ name, price, location });
            });
            return carList;
        });
        console.log(cars);
        await browser.close();
    })();
    

    This script navigates to Turo’s car rental listings, waits for content to load, and extracts vehicle names, prices, and locations. Pagination handling can be added to scrape more listings across multiple pages. Randomizing request timing and user-agent headers helps avoid detection by Turo’s anti-scraping systems.

    Fiachna Iyabo replied 2 days, 8 hours ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

Log in to reply.