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

450
Views
How to return the content of the <script> element with python

I am trying to access the content of the script element of a generic website with Selenium.

<script>...</script>

.

url = 'https://unminify.com/'
browser.get(url)
elements = browser.find_elements_by_xpath('/html/body/script[1]')
type_ = [e.get_attribute('type') for e in elements]
text_ = [e.text for e in elements]

I get an empty list for text and attribute.

screenshot from inspecting the page

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

you can create a script element and access its contents with the variable of the create element + ".text"

OR

you can put an id for a script element and access its contents with document.getElementById("scriptId").text

(you should change "scriptId" to the id of the script)

var myJs = document.getElementById("myJs");
console.log(myJs.text);
<script id="myJs">
alert("This is myJs in action.");
</script>

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!