Necesito guardar una variable de un sitio web.
La variable se define en Javascript con el siguiente código:
result = ... $('#peak_ch1').val(result);Con el siguiente código Python:
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 ie 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, ie anchor for i in l.findAll("a"): print(i.text) else: print("Error")Imprime:
<input class="setfield setfield_info" id="peak_ch1" name="peak_ch1" readonly="" style="margin-top: 5px;" type="text" value="0"/>Pero necesito el valor que js actualiza. ¿Cómo es posible recuperar el valor?