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

147
Vistas
DOM HTML Extract with javascript

I'm trying to extract information from an html page, specifically I'm trying to get the "src" url below in bold (**)

<div class="row d-block align-end" data-v-1a4e2f4c="">
<div index="0" class="row" data-v-744a5232="" data-v-1a4e2f4c="">
    <div class="col-lg-2 col-3" data-v-744a5232=""><a
            href="/libro-el-peligro-de-estar-cuerda/9788432240645/12789134" title="EL PELIGRO DE ESTAR CUERDA"
            class="py-2" data-v-744a5232=""><img title="el peligro de estar cuerda-9788432240645"
                alt="el peligro de estar cuerda-9788432240645"
                **src="https://imagessl5.casadellibro.com/a/l/t1/45/9788432240645.jpg"**
                data-src="https://imagessl5.casadellibro.com/a/l/t1/45/9788432240645.jpg" width="" height=""
                class="show-shadow cdl-img active" style="max-height:undefinedpx;max-width:undefinedpx;"
                data-v-744a5232=""></a></div>

The code I'm using does not seem to do the trick, although it works when extracting the title:

  let resultImg = xmlDoc.evaluate('./div/div/a/img[@src]', node, null, XPathResult.FIRST_ORDERED_NODE_TYPE);
    let bookImgSrc = resultImg.singleNodeValue.src;
    imgCard.src = bookImgSrc.replace('mtiny', 'large');
    divCard.appendChild(imgCard);
    console.log(imgCard);

Could someone point out what is wrong in the code and how to get the src url?

I suspect the xPathResult may be wrong.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

you can select the element then use this following code :

var myElementSrc = mySelectedElement.src ;

this is simple.

about 4 years ago · Juan Pablo Isaza Denunciar

0

probably your xpath is not correct. I tried to use "//div/div/a/img and it works

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