News Feed Forums General Web Scraping Scrape product name, price, and availability Robinson Thailand using Puppeteer?

  • Scrape product name, price, and availability Robinson Thailand using Puppeteer?

    Posted by Uduak Pompeia on 12/12/2024 at 6:08 am

    To scrape the product name from Robinson Thailand, you need to open the product page and wait for the relevant element to load. The product name is usually located in an h1 or div tag with a specific class. Use page.$eval() to extract the name text once the page has finished loading.

    const puppeteer = require('puppeteer');
    (async () => {
        // Launch browser and open page
        const browser = await puppeteer.launch({ headless: true });
        const page = await browser.newPage();
        await page.goto('https://www.robinson.co.th/product-page');
        // Scrape product name
        const productName = await page.$eval('.product-title', el => el.innerText);
        console.log('Product Name:', productName);
        await browser.close();
    })();
    
    Aiolos Fulvia replied 1 week, 2 days ago 3 Members · 2 Replies
  • 2 Replies
  • Arturs Caleb

    Member
    12/12/2024 at 11:58 am

    To scrape the price from Robinson Thailand, you’ll need to locate the element that contains the price, which is often within a span or div. Puppeteer allows you to wait for the page to load and then extract the price using page.$eval(). Be aware that the price might include currency symbols or formatting.

    const puppeteer = require('puppeteer');
    (async () => {
        // Launch browser
        const browser = await puppeteer.launch({ headless: true });
        const page = await browser.newPage();
        await page.goto('https://www.robinson.co.th/product-page');
        // Scrape price from the page
        const price = await page.$eval('.product-price', el => el.innerText);
        console.log('Price:', price);
        // Close the browser
        await browser.close();
    })();
    
  • Aiolos Fulvia

    Member
    12/14/2024 at 5:21 am

    To scrape the availability status from Robinson Thailand, you need to target the class or ID that shows whether the product is in stock or out of stock. This is usually indicated with terms like “In Stock” or “Out of Stock”. Use page.$eval() to fetch the text once the page is fully loaded.

    const puppeteer = require('puppeteer');
    (async () => {
        // Open browser and navigate to the product page
        const browser = await puppeteer.launch({ headless: true });
        const page = await browser.newPage();
        await page.goto('https://www.robinson.co.th/product-page');
        // Extract availability status
        const availability = await page.$eval('.product-availability', el => el.innerText);
        console.log('Availability:', availability);
        await browser.close();
    })();
    

Log in to reply.