I got stuck.. so many hours.. looked up hundreds of questions & answers here..
I want to grep data from a banks product website, e.g. “Delta” from:
https://wertpapiere.ing.de/Investieren/Derivat/DE000HS2JL06
(
link will be dead on 17.09.2024 as product is going to end then)
delta.text should be -0,0193
First attempt:
delta = driver.find_element(By.XPATH, '//*[text()='Delta']/following-sibling::td')
w
orks sometimes.. mostly not.. for what reason? It could be the case as “Delta” appears 10 times on the site but then:
delta = driver.find_element(By.XPATH, '//*[text()='Delta']/[5]following-sibling::td')
s
hould solve the issue but it doesn’t.
Another try:
delta = driver.find_element(By.XPATH, '//td[contains(text(), "Delta")]/following-sibling::td')
should work but doesn’t either.
The attempt with the full patch should solve the issue:
delta = driver.find_element(By.XPATH, '/html/body/main/div[2]/div/div[2]/div[1]/sh-derivative-greeks/div/div[1]/div/table/tbody/tr[2]/td[2]')
but the element can’t be found; I assume because of the dynamic IDs the site is generating.
Does anyone have the decisive tip?
Thanks so much!
Chris
Christian Linden is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.