An updated answer for those who may need it for future reference: The correct answer. decompose() You can use different methods, but decompose works in place.
Usage example:
soup = BeautifulSoup('<p>This is a slimy text and <i> I am slimer</i></p>') soup.i.decompose() print str(soup) #prints '<p>This is a slimy text and</p>'
Itβs pretty useful to get rid of detritus, like 'script', 'img', etc.
Vangel Oct 09 '16 at 15:11 2016-10-09 15:11
source share