Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

95
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda