I have some trouble finding a element here Link
I want to scrape the names of the matches using:
(I don’t like using the XPath, but otherwise I’d also get the bets that weren’t just full time result bets)
But when I run this it returns an empty list. I have tried figuring out wether the match names are within an iframe or something but I can’t figure it out. Does someone know how I can scrape these elements?
N.B. I have checked multiple times whether the XPath is actually in the HTML and it is.
so the code you are using is to wait the page to load until the xpath is found. I wrote the code below and it works. It just prints dates too, you need to adjust. However I just run it so I am confident it works. Ensure you load all the dependencies in the top. It works with class and not xpath.
driver.get("https://sports.williamhill.com/betting/en-gb/football/competitions/OB_TY295/English-Premier-League/matches/OB_MGMB/Match-Betting") WebDriverWait(driver, 10).until( lambda x: x.find_element_by_class_name('sp-o-market__title').is_displayed()) out = driver.find_elements_by_class_name('sp-o-market__title') for item in out: item = item.get_attribute('innerHTML') item = item.split('<span>') item = item.split("</span>") print(item)
Arsenal v Norwich Brentford v Brighton