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

451
Visualizações
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 Respostas
Responde à pergunta

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 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