Friday 30 August 2019

Trouble parsing tabular items from a graph located in a website

I'm trying to extract the tabular contents available on a graph in a webpage. The content of those tables are only visible when someone hovers his cursor within the area. One such table is this one.

Webpage address

The graph within which the tables are is titled as EPS consensus revisions : last 18 months.

I've tried so far with:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

link = "https://www.marketscreener.com/SUNCORP-GROUP-LTD-6491453/revisions/"

driver = webdriver.Chrome()
driver.get(link)
wait = WebDriverWait(driver, 10)
for items in wait.until(EC.presence_of_all_elements_located((By.CSS_SELECTOR, "#graphRevisionBNAeec span > table tr"))):
    data = [item.text for item in items.find_elements_by_css_selector("td")]
    print(data)
driver.quit()

When I run the above script, It throws thie error raise TimeoutException(message, screen, stacktrace):selenium.common.exceptions.TimeoutException: Message: pointing at this for items in wait.until() line.

Output from a single table out of many should look like:

Period: Thursday, Aug 22, 2019
Number of upgrading estimates: 0
Number of unchanged estimates: 7
Number of Downgrading estimates: 0
High Value: 0.90 AUD
Mean Value: 0.85 AUD
Low Value: 0.77 AUD

How can I get the content of those tables from that graph?



from Trouble parsing tabular items from a graph located in a website

No comments:

Post a Comment