Search

Reply to comment

Python BeautifulSoup Grab All Text Inside Html-Tag-Block

BeautifulSoup Dispose of a very Nice function that permit to Grab all the Text Contained Inside a Tag-Block.

For Example if you have an Html block to Parse like this:

<div class="first">
    <h3 class="second">The Title</h3>
    <a class="second">The Anchor
           <span class="third">The Span</a>
    </a>
</div>

And you need to Get all the simple Text Contained inside of the Block marked by the <div> Tag.

You can simply Catch All Text Inside Html with Single Magical BeautifulSoup Directive like:

BeautifulSoup(htmlBlock).findAll(text=True)

This will Give you as Result an Array like this:

[u'The Title Text', u'The Anchor Text', u'The Span Text']

 

The BeautifulSoup is Really the Exilarating Soup of "Alice in the Wonderland" we can Eat&Drink.

Reply

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer