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

526
Visualizações
Python - How do I receive a div tag that loaded by a js script using BeautifulSoup?
import requests
from bs4 import BeautifulSoup

response = requests.get("...")
soup = BeautifulSoup(response.text, "html.parser")
print(soup.prettify())

In my current output for a div that I looking for was only able to output this <div id="root"></div>, on the website it just load all div inside of div id="root". I wanted to load the div that loaded by a JS Script. The output that I wanted to get was

<div id="root">
    <div id="dark-id" class="my-class">dark</div>
   <div>
     <div id="light-id" class="other-class">light</div>
   </div>
</div>

Was it possible to load a HTML Tag that loaded by a JS Script? If its possible, does anyone can help me?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

If I understand correctly, then there is no way for you to do this using beautiful soup. It's not really a question of how to load divs that were loaded by a script, but rather how to use a web browser to load a page with JavaScript and then grab the elements from that page.

Browser webdrivers hit the page and then execute the javascript, populating the page with the elements. Beautiful soup doesn't do that. You could use a webdriver and then parse the webdriver's html output, but it sounds like you might be looking for something simpler than that.

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