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

107
Vistas
Puppeteer scrape div tag elements returning some nulls values

I'm trying to grab products from ebay and open them on amazon and get the asins from the search results.

So far the script is scraping some of asins from the list of ebay titles that loops through, but then there is quite a lot of random blanks. Im guessing this may be due to if the page has fully rendered. i did try some waits but with no luck.

     const puppeteer = require('puppeteer');


     const URL = "https://www.amazon.co.uk/";
     const selectors = {
         searchBox : '#twotabsearchtextbox',   
         productLinks: 'span.a-size-base-plus.a-color-base.a-text-normal',
         productTitle: '#productTitle'
    
     };

     let browser;

   (async () => {
       
 
     browser = await puppeteer.launch( {headless: false});

   

 
    const page = await browser.newPage();

    
     await page.goto('https://www.ebay.co.uk/sch/jmp_supplies/m.html?_trkparms=folent%3Ajmp_supplies%7Cfolenttp%3A1&rt=nc&_trksid=p2046732.m1684');
    

   
     const ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36";
    await page.setExtraHTTPHeaders({"Accept-Language": "en-US,en;q=0.9"});
    await page.setUserAgent(ua);
 
    
    
    //Get product titles from ebay
    const grabTitles = await page.evaluate(() =>{
        const itemTitles = document.querySelectorAll('#e1-11 > #ResultSetItems > #ListViewInner > li > .lvtitle > .vip');
        var items = []
        itemTitles.forEach((tag) =>{
            items.push(tag.innerText)
        })
 
        return items
    })
 
 
   
   for (const title of grabTitles) {
    const page = await browser.newPage();
await page.goto("https://www.amazon.co.uk/");
await page.type("#twotabsearchtextbox", title);



await Promise.all([
  await page.keyboard.press("Enter"),
 

  page.waitForNavigation(),
]);


const attr = await page.$$eval("div.s-result-item.s-asin.sg-col-0-of-12.sg-col-16-of-20.sg-col.s-widget-spacing-small.sg-col-12-of-16",
 el => el.map(x => x.getAttribute("data-asin")));


console.log(attr.slice(0, 5));


 }

})()


  .catch(err => console.error(err))
  .finally(() => browser?.close())
 ;
about 4 years ago · Juan Pablo Isaza
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