Forum Replies Created

  • When scraping Shopee Thailand, product reviews can be accessed by navigating through the product page and extracting review data. Puppeteer allows you to emulate user actions like scrolling, ensuring that all reviews load before extracting them. You can gather product ratings and user comments by targeting the right classes and using page.$eval() or page.$$eval() to fetch the review content.

    const puppeteer = require('puppeteer');
    (async () => {
        const browser = await puppeteer.launch({ headless: true });
        const page = await browser.newPage();
        await page.goto('https://shopee.co.th/product-page-url');
        // Scroll to load reviews
        await page.evaluate(() => {
            window.scrollBy(0, window.innerHeight);
        });
        // Scrape reviews
        const reviews = await page.$$eval('.review-item', items => {
            return items.map(item => {
                const name = item.querySelector('.review-author').innerText;
                const rating = item.querySelector('.rating-star').innerText;
                const reviewText = item.querySelector('.review-text').innerText;
                return { name, rating, reviewText };
            });
        });
        console.log(reviews);
        await browser.close();
    })();
    
  • 675a8d1816ce5 bpthumb

    Prashant Sanjiv

    Member
    12/12/2024 at 7:19 am in reply to: How to send a JSON POST request using cURL?

    Using the –retry option in cURL helps manage temporary network failures by retrying the request automatically after a delay.