I have the following tag:
<div class="example_class">
<b>
<img src="image_source"/>
extra infomation
<a href="reference">
extra information
</a>
</b>
.
<br/>
<br/>
This is the text I want to get.
<lt>
</lt>
br /
<gt>
</gt>
<lt>
</lt>
br /
<gt>
</gt>
<lt>
</lt>
br /
<gt>
</gt>
This is the rest of the text.
</div>
I want to get the text 'This is the text I want to get. This is the rest of the text.', but I don't know how. When I try the following:
soup_result = soup.find('div',{'class': 'example_class'})
result = soup_result.get_text()
I get:
'\n\n\n extra information\n \n extra information\n \n\n .\n \n\n This is the text I want to get.\n \n\n br /\n \n\n\n\n br /\n \n\n\n\n br /\n \n\n This is the rest of the text.'
How do I make sure 'extra information' and the newlines with a lot of whitespaces in between are not in the result?