-1

The html div tag is something like this

<div class="_1vC4OE _37U4_g">
₹
<!-- -->
15,190
</div>

And I want to extract the numerical figure 15,190. The code which i wrote is something like this

from selenium import webdriver
driver = webdriver.Chrome()
url = 'required url'
driver.get(url)
elem = driver.find_element_by_css_selector('div._37U4_g')
price = elem.get_attribute('value')
print('price of the item is:', price)
driver.close()

But it returns None. Thanks in advance!

1 Answers1

0

Try this

from selenium import webdriver
driver = webdriver.Chrome()
url = 'required url'
driver.get(url)
elem = driver.find_element_by_css_selector('div._37U4_g')
price = elem.text
print('price of the item is:', price)
driver.close()

Your code will return nothing because there is no attribute called value from the HTML that you've posted.

Your code will result in correct output in case the HTML was like this

<div class="_1vC4OE _37U4_g" value = "₹15,190></div>
demouser123
  • 4,108
  • 9
  • 50
  • 82