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

97
Visualizações
Having trouble scraping a particular element on a website using Puppeteer

I am trying to scrape the key features part of the website with the URL of: "https://www.alpinestars.com/products/stella-missile-v2-1-piece-suit-1" using puppeteer - however, whenever I try to use a selector that works on the chrome console for the website the output for my code is always an empty array or object. For example both document.querySelectorAll("#key\ features > p") and document.getElementById('key features') both return as empty arrays or objects when I output it through my code but work via chrome console.

I have attached my code below:

const puppeteer = require('puppeteer');

async function getDescripData(url) {
    const browser = await puppeteer.launch({headless: true});
    const page = await browser.newPage();
    await page.goto(url);
    const descripFeatures = await page.evaluate(() => {
        const tds = Array.from(document.getElementById('key features'))
        console.log(tds)
        return tds.map(td => td.innerText)
    });
   console.log(descripFeatures)
    await browser.close();
    return {
        features: descripFeatures
    }
}

How should I go about overcoming this issue?

Thanks in advance!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Your problem is in Array.from you are passing a non-iterable object and return null.

This works for me:

const puppeteer = require('puppeteer');
const url = 'https://www.alpinestars.com/products/stella-missile-v2-1-piece-suit-1';
      (async () => {
        const browser = await puppeteer.launch({
          headless: false,
          defaultViewport: null,
          args: ['--start-maximized'],
          devtools: true
        });
        const page = (await browser.pages())[0];
        await page.goto(url);
        const descripFeatures = await page.evaluate(() => {
          const tds = document.getElementById('key features').innerText;
          return tds.split('• ');
        });
        console.log(descripFeatures)
        await browser.close();
      })();
about 4 years ago · Juan Pablo Isaza Relatório
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