Scraping Yahoo Finance stock earnings release dates with Selenium

I would like to scrape all company info under “Symbol”, “Name”, and “Earnings Call Time” from the following page: Company Earnings Calendar - Yahoo Finance

I would also like selenium to go to the very next earnings date available and grab the same info as above. For example, today is November 18, so I would like to grab the same info for November 19.

I have tried several ways of doing this with selenium but cannot.

Thanks for any of your help!

2 Likes

For starters the URL takes date parameters:

https://finance.yahoo.com/calendar/earnings?day=2020-11-19

So you need to construct that url as such:

import datetime
tomorrow = (datetime.date.today() + datetime.timedelta(days=1)).isoformat() #get tomorrow in iso format as needed
url = "https://finance.yahoo.com/calendar/earnings?day="+tomorrow
print ("url: " + url)

then you need to grab the elements you need to get data. For example:

driver.find_element_by_xpath("//*[@id='cal-res-table']//table")

See working with tables in selenium here: https://www.techbeamers.com/handling-html-tables-selenium-webdriver/ and https://www.lambdatest.com/blog/how-to-handle-web-table-in-selenium-webdriver/

But you’ll want to use find_elements to find the rows, and then select the td’s you need from there.