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

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

    Posted by Shena Brigid on 12/11/2024 at 11:55 am

    To scrape the product name from Klook Thailand, you can use Puppeteer to navigate to the product page and target the HTML element that contains the product name. The name is typically stored within an h1 or span tag with a specific class. You’ll need to ensure that the page is fully loaded using waitForSelector() before extracting the text.

    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 productName = await page.$eval('.activity-title', el => el.innerText);
        console.log('Product Name:', productName);
        await browser.close();
    })();
    
    Elisabeth Ishita replied 1 week, 3 days ago 3 Members · 2 Replies
  • 2 Replies
  • Coronis Osmond

    Member
    12/12/2024 at 10:18 am

    To scrape the price from Klook Thailand, use Puppeteer to extract the price information, which is usually found inside a span or div element with a class related to pricing. After navigating to the product page, wait for the price element to be visible, then extract it using page.$eval().

    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 price = await page.$eval('.price', el => el.innerText);
        console.log('Price:', price);
        await browser.close();
    })();
    
  • Elisabeth Ishita

    Member
    12/12/2024 at 11:04 am

    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();
    })();
    

Log in to reply.