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

146
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 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