I have a html below:
<span class="ui-cfs-sn-l" xpath="1">
ABC
<span class="ui-cfs-txt">°⌃</span>
</span>
I used the following python code to extract the text which returns ABC°⌃
element = driver.find_element(by=By.XPATH, value="//span[@class='ui-cfs-sn-l']")
result = element.text
Is there a way to extract just the text before the inner span? The solution should return ABC
2
Answers
You could use Pythons BeautifulSoup4 library to achieve this.
Here is an example:
Edit:
You can use BeautifulSoup with Selenium as described in this answer
You can extract the text like this:
or:
or: