News Feed Forums General Web Scraping How can I scrape product name, price, rating from HomePro Thailand -Puppeteer?

  • How can I scrape product name, price, rating from HomePro Thailand -Puppeteer?

    Posted by Nagendra Berna on 12/11/2024 at 12:37 pm

    To scrape the product name from HomePro Thailand, you can use Puppeteer to extract the text from the specific HTML element that contains the name. Usually, the product name is located within a div or span tag. Using page.$eval() after ensuring the page has fully loaded will allow you to extract the product name easily.

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

    Member
    12/12/2024 at 11:57 am

    Scraping the price from HomePro Thailand involves targeting the HTML element containing the product’s price, which is typically inside a span or div with a price-related class. After waiting for the page to load, you can extract the price text using Puppeteer’s page.$eval() method. The price will often include the currency symbol and might be formatted with thousands separators.

    const puppeteer = require('puppeteer');
    (async () => {
        const browser = await puppeteer.launch({ headless: true });
        const page = await browser.newPage();
        await page.goto('https://www.homepro.co.th/en/product-page');
        const price = await page.$eval('.product-price', el => el.innerText);
        console.log('Price:', price);
        await browser.close();
    })();
    
  • Candice Agata

    Member
    12/13/2024 at 6:56 am

    To scrape the rating from HomePro Thailand, you’ll need to locate the element that contains the review score or star rating. This is usually found within a span tag or a div class that includes stars or text indicating the product’s rating. Using Puppeteer, you can extract the rating text once the page is fully loaded.

    const puppeteer = require('puppeteer');
    (async () => {
        const browser = await puppeteer.launch({ headless: true });
        const page = await browser.newPage();
        await page.goto('https://www.homepro.co.th/en/product-page');
        const rating = await page.$eval('.product-rating', el => el.innerText);
        console.log('Rating:', rating);
        await browser.close();
    })();
    

Log in to reply.