News Feed Forums General Web Scraping How can I scrape product name, price, availability from BigC Thailand -Puppeteer

  • How can I scrape product name, price, availability from BigC Thailand -Puppeteer

    Posted by Osman Devaki on 12/11/2024 at 12:06 pm

    To scrape the product name from BigC Thailand, you’ll first need to navigate to the specific product page and then locate the element containing the product name. It’s usually found within an h1 or span tag. You can extract the product name by using Puppeteer’s page.$eval() method after making sure 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.bigc.co.th/en/product-page');
        const productName = await page.$eval('.product-name', el => el.innerText);
        console.log('Product Name:', productName);
        await browser.close();
    })();
    
    Narayanan Syed replied 1 week, 3 days ago 4 Members · 3 Replies
  • 3 Replies
  • Nagendra Berna

    Member
    12/11/2024 at 12:39 pm

    For error handling, I add the -w flag to format response details, such as HTTP status codes or response times. This ensures I quickly detect and address problems.

  • Elisabeth Ishita

    Member
    12/12/2024 at 11:05 am

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

    Member
    12/12/2024 at 11:39 am

    Scraping availability from BigC Thailand is similar to scraping the product price, but here you target the availability status, such as “In Stock” or “Out of Stock”. After navigating to the product page, use Puppeteer to extract the availability text by targeting the appropriate element using page.$eval(). This information is often displayed as a simple text string or inside a span.

    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 availability = await page.$eval('.availability-status', el => el.innerText);
        console.log('Availability:', availability);
        await browser.close();
    })();
    

Log in to reply.