Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

163
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!