from BeautifulSoup import BeautifulSoup soup = BeautifulSoup('<html><p>abc</p><script></script><br />abc</html>') for tag in soup.recursiveChildGenerator(): .... if hasattr(tag, 'name') and tag.name in ['script', 'iframe']: ........tag.extract() print soup.renderContents('utf-8')