Python BeautifulSoup scrape Yahoo Finance value -


i attempting scrape 'full time employees' value of 110,000 yahoo finance website.

the url is: http://finance.yahoo.com/quote/aapl/profile?p=aapl

i have tried using beautiful soup, can't find value on page. when in dom explorer in ie, can see it. has tag parent tag has parent

has parent . actual value in custom class of data-react-id.

code have tried:

from bs4 import beautifulsoup bs html=`http://finance.yahoo.com/quote/aapl/profile?p=aapl` r = requests.get(html).content soup = bs(r) 

not sure go.

the problem in "requests" related part - the page download requests not same see in browser. browser executed of javascript, made multiple asynchronous requests needed load page. and, particular page quite dynamic itself. there lot happening on "client-side".

what can load page in real browser automated selenium. working example:

from selenium import webdriver selenium.webdriver.common.by import selenium.webdriver.support import expected_conditions ec selenium.webdriver.support.wait import webdriverwait  driver = webdriver.chrome() driver.maximize_window() driver.get("http://finance.yahoo.com/quote/aapl/profile?p=aapl")  # wait full time employees visible wait = webdriverwait(driver, 10) employees = wait.until(ec.visibility_of_element_located((by.xpath, "//span[. = 'full time employees']/following-sibling::strong"))) print(employees.text)  driver.close() 

prints 110,000.


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -