0

I'm trying to extract some odds from a page using Selenium ChromeDriver, since the data is dynamic. The "find elements by XPath expression" usually works with these kind of websites for me, but this time, it can't seem to find the element in question, nor any element that belong to the section of the page that shows the relevant odds.

I'm probably making a simple error - if anyone has time to check the page out I'd be very grateful! Sample page: Nordic Bet NHL Odds

driver.get("https://www.nordicbet.com/en/odds#?cat=&reg=&sc=50&bgi=36")
time.sleep(5)
dayElems = driver.find_elements_by_xpath("//div[@class='ng-scope']")
print(len(dayElems))

Output:

0
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Daniel Slätt
  • 751
  • 2
  • 15
  • 28
  • 3
    Please read why a [screenshot of HTML or code or error is a bad idea](https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors). Consider updating the Question with formatted text based relevant HTML, code trials and error stack trace. – undetected Selenium Feb 28 '18 at 11:52
  • It's preferable not to use `time.sleep(5)` but wait for a specific element to appear or the spinning wheel disappear. The xpath itself is fine but will probably give the wrong element. Try right-clicking on the desired element in the browser and inspect it. – Maximilian Peters Feb 28 '18 at 12:18
  • I've tried using WebdriverWait (until presence of element by Xpath) but it just goes to timeout. It seems selenium can't access this part of the website at all. – Daniel Slätt Feb 28 '18 at 13:17

1 Answers1

3

It was a problem I used to face...


It is in another frame whose id is SportsbookIFrame. You need to navigate into the frame:

driver.switch_to_frame("SportsbookIFrame")
dayElems = driver.find_elements_by_xpath("//div[@class='ng-scope']")
len(dayElems)

Output:

26

For searching iframes, they are usual elements:

iframes = driver.find_elements_by_xpath("//iframe")
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
patpat
  • 664
  • 1
  • 5
  • 14