Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Finding specifig value in class – Selenium (Python)

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’ ?

<div class="weather_yesterday_mean">21,73</div>

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can just use querySelector that accepts CSS selectors. I personally like them way more than XPath:

elem = driver.find_element_by_css_selector('div.weather_yesterday_mean')
result = elem.text

If that suits you, please read a bit about CSS selectors, for example here: https://www.w3schools.com/cssref/css_selectors.asp

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading