Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

443
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda