I’m trying to scrap a website using selenium. I tried using XPATH, but the problem is that the rows on the website change over time…
How can I scrap the website, so that it gives me the output ‘21,73’ ?
JavaScript
x
2
1
<div class="weather_yesterday_mean">21,73</div>
2
Advertisement
Answer
You can just use querySelector that accepts CSS selectors. I personally like them way more than XPath:
JavaScript
1
3
1
elem = driver.find_element_by_css_selector('div.weather_yesterday_mean')
2
result = elem.text
3
If that suits you, please read a bit about CSS selectors, for example here: https://www.w3schools.com/cssref/css_selectors.asp