Home > Software engineering >  Formatting the output result using Selenium Python to show text in a single line
Formatting the output result using Selenium Python to show text in a single line

Time:08-05

I have the following sample html code, for which I am trying to scrape the data:

<div >
    <div >
        <span >
            <span seconddigit">
            <span thirddigit">
            <span 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.

CodePudding user response:

Try this one

threedigits = ''.join(threedigits.split())

or

threedigits = threedigits.replace('\n', '')

  • Related