-1

Anyone know how to get the text from the below html code. Just I need '383' as a text by using CSS selector from the below html.

<td align="right" style="background-color: rgb(147, 191, 179); color: rgb(255, 255, 255);" xpath="1">383&nbsp;&nbsp;</td>

1 Answers1

0

First start the webdriver

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service

your_chromedriver_path = '...'
driver = webdriver.Chrome(service=Service(your_chromedriver_path))

then load the webpage

url = '...'
driver.get(url)

then find the td element

td = driver.find_element(By.XPATH, '//td')

finally you can get its text by using one of the following (see differences here)

td.text
td.get_attribute('innerHTML')
td.get_attribute('innerText')
td.get_attribute('textContent')
sound wave
  • 3,191
  • 3
  • 11
  • 29