Forum Replies Created

  • To scrape the price from BigC Thailand, you can use Puppeteer to select the HTML element containing the price. It’s usually found in a span or div tag with a specific class indicating price. Once the page has fully loaded, use page.$eval() to extract the price text, which is typically formatted with currency symbols.

    const puppeteer = require('puppeteer');
    (async () => {
        const browser = await puppeteer.launch({ headless: true });
        const page = await browser.newPage();
        await page.goto('https://www.bigc.co.th/en/product-page');
        const price = await page.$eval('.product-price', el => el.innerText);
        console.log('Price:', price);
        await browser.close();
    })();
    
  • For scraping the rating of a product on Klook Thailand, target the span or div tag that contains the rating information. Use Puppeteer’s page.$eval() to extract the rating text after waiting for the page to load completely. Be mindful that ratings can be in the form of stars or a numerical value, depending on the layout.

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