I'm trying to extract some data with selenium and python from a website. Here is some code I use until now:
url = 'https://www.kicker.de/1894559/spieldaten/bayern-muenchen-14/borussia-mgladbach-15'
chrome = webdriver.Chrome()
select = Select(chrome.find_element_by_id('selOptaPlayer1'))
select.select_by_value('57598')
It is possible to open the URL, select the player on the website. But I can't extract some data from the player. I get the error that selenium can't find the xpath. With google help, the issue can be with iframes. Now my question is, how can I find out in which iframe is the data located?
Please find below solution to select 57598 value option using option[text()='Alaba, David']
Solution 1:
from selenium import webdriver
driver = webdriver.Chrome(executable_path=r"C:\New folder\chromedriver.exe")
driver.get('https://www.kicker.de/1894559/spieldaten/bayern-muenchen-14/borussia-mgladbach-1')
driver.find_element_by_xpath("//select[@id='selOptaPlayer1']/option[text()='Alaba, David']").click()
Solution 2:
Also you can use below code for the same :
from selenium import webdriver
from selenium.webdriver.support.ui import Select
driver = webdriver.Chrome(executable_path=r"C:\New folder\chromedriver.exe")
driver.get('https://www.kicker.de/1894559/spieldaten/bayern-muenchen-14/borussia-mgladbach-1')
select.select_by_value('57598')
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments