javascript - How to let a webpage load before scraping with BeautifulSoup? -
i'm trying make small snow day calculator python program, , figured use beautifulsoup job. able scrape page, noticed result 0%. noticed because takes website second or 2 after loads display percentage, , because of website's reactive javascript.
how able load webpage, wait two-three seconds, , scrape webpage snow day percentage?
code:
import urllib import bs4 def getpercent(zip): url = "https://snowdaypredictor.com/result.html?q="+zip print url page = urllib.urlopen(url) soup = bs4.beautifulsoup(page,'html.parser') name_box = soup.find('span', attrs = {'id': 'result-percent'}) print name_box.text.strip(),"%" getpercent(raw_input("what zip code?"))
Comments
Post a Comment