Issue
I have the following sample html code, for which I am trying to scrape the data:
<div class="main">
<div class="firstdigitinside">
<span class="firstdigit">
<span class="firstdigithere>1
</span>
</span>
<span class="seconddigit">
<span class="seconddigithere>2
</span>
</span>
<span class="thirddigit">
<span class="thirddigithere>3
</span>
</span>
</div>
</div>
My Code is as Follows:
threedigits = driver.find_element("xpath", ".//div[@class='main']").text
print(threedigits, sep="", end="")
My Output is as follows:
1
2
3
The result I am trying to achieve is supposed to look like this:
123
The output result is supposed to be in a single row without any spaces in between.
Solution
Try this one
threedigits = ''.join(threedigits.split())
or
threedigits = threedigits.replace('\n', '')
Answered By - Hanna
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.