1

Hello i am trying to webscrape a web page using pyhton and selenium. The information i am trying to get from the page is match information / score board. for example the current set, the players name, the points each player has. i keep getting a TimeoutException. can someone show me how i can retrieve this information below is a link to an example of the page.

https://www.bovada.lv/sports/tennis/itf-men/chile-singles/a-tabilo-i-monzon-201811211325

below is my code

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
from bs4 import BeautifulSoup

driver = webdriver.Chrome()  
driver.maximize_window()
wait = WebDriverWait(driver, 50)
small_wait = WebDriverWait(driver, 50)


driver.execute_script('window.open("https://www.bovada.lv/sports/tennis/itf-men/chile-singles/a-tabilo-i-monzon-201811211325","_self")')

#//*[@id="tracker__header"]
dat = []
try:
    dat.append([wait.until(EC.presence_of_element_located((By.XPATH, '//*[@id="tracker__header"]/div/div[1]/div/div[2]'))).text])
except TimeoutException:
    print('error')

driver.quit() 

below is the information i want to get from the website enter image description here

2 Answers 2

2

You need to switch to iframe to get value:

driver.switch_to.frame(driver.find_element_by_css_selector('iframe[id^="iframe-tracker-"]'))
try:
    dat.append(wait.until(EC.presence_of_element_located((By.XPATH, '//*[@id="tracker__header"]/div/div[1]/div/div[2]'))).text)
except TimeoutException:
    print('error')
Sign up to request clarification or add additional context in comments.

Comments

0

What you need to do is most likely switch to frames. You can do that by inspecting element and find the iframe section. Right click on is and copy the x-path.

iframe = driver.find_element_by_xpath('YOUR IFRAME XPATH)
driver.switch_to.frame(iframe)

Now you can run your code just fine, hopefully.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.