Sam Sam - 1 year ago 97
Python Question

Can I remove script tags with BeautifulSoup?

Can script tags and all of their contents be removed from HTML with BeautifulSoup, or do I have to use Regular Expressions or something else?

Answer Source
>>> soup = BeautifulSoup('<script>a</script>baba<script>b</script>')
>>> [s.extract() for s in soup('script')]
>>> soup
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download