-
How can I scrape product reviews from Shopee Thailand using Node.js n Puppeteer?
Puppeteer is great for scraping Shopee Thailand, especially when the content is dynamically loaded via JavaScript. You’ll need to load the page and extract product reviews once the page is fully rendered. A common challenge is handling infinite scrolling, where products or reviews are loaded as you scroll down. Use page.evaluate() to grab reviews, ratings, and other metadata after the page has rendered.
const puppeteer = require('puppeteer'); (async () => { const browser = await puppeteer.launch({ headless: false }); const page = await browser.newPage(); await page.goto('https://shopee.co.th/product-page-url'); // Wait for the review section to load await page.waitForSelector('.shopee-review-item'); // Extract review data const reviews = await page.evaluate(() => { const reviewElements = document.querySelectorAll('.shopee-review-item'); const reviews = []; reviewElements.forEach(review => { const username = review.querySelector('.shopee-user-name').textContent; const rating = review.querySelector('.shopee-star-rating').textContent; const comment = review.querySelector('.shopee-review-item__content').textContent; reviews.push({ username, rating, comment }); }); return reviews; }); console.log(reviews); await browser.close(); })();
Log in to reply.