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

164
Visualizações
How to get text inside script tag html?

I tried to get this link 'video_versions' text from this url https://www.instagram.com/p/Cahc9hbr9Jp/ but it doesn't show anything. Here's my code

  var c = document.createElement("html");
  c.innerHTML = content;
  scripts = c.querySelectorAll('script');
  script = scripts[scripts.length-2];

  console.log(script.innerHTML.split('video_versions').pop());
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

This is because you aren't getting the innerHTML property of the script element object, you are simply returning the object of the element from the DOM.

try:

script = scripts[scripts.length-2].innerHTML;
about 4 years ago · Juan Pablo Isaza Relatório

0

Although scriptElement.textContent is perhaps more appropriate than scriptElement.innerHTML both seem to work if they work at all.

However they only retrieve text between the opening and closing <script> tags present in the HTML source, so they are only good for reading the content of inline scripts. The URL posted doesn't strike me as the kind of page with hand-crafted inline scripts.

If you want to read the script text fetched by a script tag with a src attribute specifying its URL, you would need to repeat the fetch process in JavaScript using either the Fetch or XMLHttpRequest API for the same URL. The success of doing so depends on the server's cross origin policy allowing it.

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