Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

135
Visualizações
Cannot select element using Puppeteer

I'm using puppeteer to scrape some data off of a website, but all of my selections for a certain element are always undefined.

    const tempFunction = await page.evaluate(() => {
        let a = document.querySelectorAll(".flex.flex-wrap.w-100.flex-grow-0.flex-shrink-0.ph2.pr0-xl.pl4-xl.mt0-xl.mt3")
        let container = document.querySelector(".flex.flex-wrap.w-100.flex-grow-0.flex-shrink-0.ph2.pr0-xl.pl4-xl.mt0-xl.mt3")
        let b = container.getElementsByClassName("mb1 ph1 pa0-xl bb b--near-white w-33")
        return b
    })

For some reason this code always returns undefined, but similar code works fine.

    const checkData = await page.evaluate(() =>{
        let tempArray = []
        let element = document.querySelectorAll('.weather-block')
        
        tempArray.push(element[0].innerText)  
        return tempArray
    })

Even when trying to use specific selectors or id's, I only get undefined. Not sure where to go from here.

about 4 years ago · Santiago Gelvez
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda