1

Using the command:

cena_postov=driver.find_elements_by_xpath("//*[starts-with(@id, 'td_')]/td[11]/a[1]/span/span")
for spisok_cen in cena_postov:
  print(spisok_cen.get_attribute('textContent'))

I get a text list. I want to convert it to a number using

if int(spisok_cen.get_attribute('textContent'))<=10 and int(spisok_cen.get_attribute('textContent'))>=12000:
 print('anything')

but the symbol ' bothers me. I get an error invalid literal for int() with base 10: ": 6'000 how to make python ignore this character?

dpapadopoulos
  • 1,834
  • 5
  • 23
  • 34

1 Answers1

0

You can use replace method to remove unnecessary ':

if int(spisok_cen.get_attribute('textContent').replace("'", ""))<=10 and int(spisok_cen.get_attribute('textContent').replace("'", ""))>=12000:
    print('anything')

Also you can find solution with locale here.

Sers
  • 12,047
  • 2
  • 12
  • 31
  • 1
    I added a couple more .replace("'", "").replace(":", "").replace(" ", "") and it worked. Thank you, I will read the second method later. –  Feb 20 '19 at 08:25