0
votes

I would like to scrape https://www.sportsbookreview.com/betting-odds/college-football/totals/1st-half/?date=20180825 where I would like to get only text from class adjust-1uDgI which is a child of class numbersContainer-29L5c with specific tag data-vertical-sbid="238". So I would like to get odds from Pinnacle and I should get 30.5 and 23 for this page.

I'm not sure how can I get it, should I use driver.find_elements_by_xpath() or driver.find_elements_by_class_name()

This is my code for now where I wanted to get data with that class but I get an empty list

driver = webdriver.Chrome(executable_path=binary_path)
driver.get('https://www.sportsbookreview.com/betting-odds/college-football/totals/1st-half/?date=20180825')
element = elements = driver.find_elements_by_class_name("adjust-1uDgI")
print(element)
driver.quit()
1

1 Answers

1
votes

What might be the problem is that you didn't wait for the webpage to load. Try this:

from selenium.webdriver import Chrome
from selenium.webdriver.support.ui import WebDriverWait

driver = Chrome(executable_path=binary_path)
driver.get('https://www.sportsbookreview.com/betting-odds/college-football/totals/1st-half/?date=20180825')
element = elements = WebDriverWait(driver, 5).until(lambda d: d.find_elements_by_class_name("adjust-1uDgI"))

print(element)
driver.quit()