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

222
Visualizações
Webscrap product price with javascript

im making a blog were i will show a product and all of it's prices on all the websites that sell this product, but i whant the prices to be up to date so i decided to make a webscrap script so i can allways get the updated product price, but it does not seem to work... i searched all over the internet and i didn't find anyone that can do this, can you guys help me fix my code? :D

 var dd = document.querySelectorAll("dd");
   
   var xhr = new XMLHttpRequest();

   xhr.open("GET","https://www.chewy.com/blue-buffalo-life-protection-formula/dp/32041")
   xhr.responseType = "document";

   xhr.onload = function(){
       if(xhr.readyState = 4 && xhr.status == 200)
       {
           var response = xhr.responseXML.querySelectorAll("#advertised-price")

           dd[0].innerText = response[1].children[1].textContent;
           
           console.log(response);
       }
   };

   xhr.onerror = function()
   {
       console.error(xhr.status, xhr.statusText);
   }

   xhr.send();

https://codepen.io/galusk0149007/pen/zYRoovY

about 4 years ago · Juan Pablo Isaza
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