-
Scrape product name, price, and rating from a Thai e-commerce site with Node.js?
To scrape the product name from an e-commerce site in Thailand, you can use Puppeteer to launch the page and use page.evaluate() to extract the text from the element containing the product name. This will typically be inside a <div> or <h1> tag with a specific class. Ensure that you wait for the page to load fully before scraping the data.
const puppeteer = require('puppeteer'); (async () => { const browser = await puppeteer.launch({ headless: true }); const page = await browser.newPage(); await page.goto('https://example.com/product-page'); const name = await page.$eval('.product-title', el => el.innerText); console.log('Product Name:', name); await browser.close(); })();
Log in to reply.