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

124
Visualizações
How to retrieve a variable from a website while JavaScript updates it

I need to save a variable from a website.

On the left there is the website page where the value I need to save (peak_ch1) is indicated, on the right there is the corresponding htlm code.

The variable is defined in Javascript with the following code:

result = ...

$('#peak_ch1').val(result);

With the following Python code:

import requests
from bs4 import BeautifulSoup

url= ...
  
#open with GET method
resp=requests.get(url)
  
#http_respone 200 means OK status
if resp.status_code==200:
    print("Successfully opened the web page")
    print("The news are as follow :-\n")
  
    # we need a parser,Python built-in HTML parser is enough .
    soup=BeautifulSoup(resp.text,'html.parser')    

    # l is the list which contains all the text i.e news 
    l=soup.find("input",{"id":"peak_ch1"})
    print(l)
  
    #now we want to print only the text part of the anchor.
    #find all the elements of a, i.e anchor
    for i in l.findAll("a"):
        print(i.text)
else:
    print("Error")

It prints:

<input class="setfield setfield_info" id="peak_ch1" name="peak_ch1" readonly="" style="margin-top: 5px;" type="text" value="0"/>

But I need the value that is updated by js. How is it possible to retrieve the value?

about 4 years ago · Santiago Trujillo
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