Failing in WebScraping products names PUPPETEER JS

So this is my code right now

My goal is to WebScrape and print in console the first 10 products names in https://www.nike.com.br/Snkrs#estoque

However, it’s returning the same name 10 times

"Kybrid S2Pineapple Comprar

Kybrid S2Pineapple Comprar

...

Kybrid S2Pineapple Comprar"
    const puppeteer = require('puppeteer');
    const { stringify } = require('querystring');
    
    async function Teste(){
        const browser = await puppeteer.launch({
            headless: false
        })
        page = await browser.newPage();
        
        await page.goto('https://www.nike.com.br/Snkrs#estoque');
    
        await page.waitForSelector('#DadosPaginacaoEstoque');
    
        var s = 10
        var i = 1
        
        while (i != s){
            w = await page.evaluate('document.querySelector("#DadosPaginacaoEstoque > div:nth-child(1) > div:nth-child("+String(i)+") > div > div.produto__detalhe").innerText');
            console.log(w);
            i = i + 1;
        }
        console.log(s)
    }
    Teste();

How do I fix this?

90 thoughts on “Failing in WebScraping products names PUPPETEER JS”

Leave a Comment