-
Scrape product name, price, and stock from Tops Thailand using Puppeteer?
To scrape the product name from Tops Thailand, you can use Puppeteer to open the product page and locate the div or h1 tag containing the name. The product name is usually found in a specific class within these tags. After waiting for the page to load fully, use page.$eval() to extract the inner text.
const puppeteer = require('puppeteer'); (async () => { const browser = await puppeteer.launch({ headless: true }); const page = await browser.newPage(); await page.goto('https://www.tops.co.th/en/product-page'); const productName = await page.$eval('.product-name', el => el.innerText); console.log('Product Name:', productName); await browser.close(); })();
Log in to reply.