Python selenium string to int -


i've tried of examples on stackoverflow can't find way. have 2 questions, how make string text..

posts = driver.find_elements_by_class_name("currency-chaos") numberofitems = 1 post in posts:     numberofitems = numberofitems + 1     print(numberofitems)     print(post.text) 

and how remove letter text, transfer int?

you use regular expression remove non digit characters , parse number float :

import re  value = float(re.sub(r"[^\d.]", "", post.text)) print("value: %s" % value) 

Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -