Scrubber is a white-listing HTML sanitizer. It uses BeautifulSoup to parse an HTML document and removes any tags and attributes that are not specifically allowed. Some other features of scrubber include:
Stable releases of Scrubber can be installed using easy_install or pip.
You can find the latest version of scrubber at http://github.com/samuel/python-scrubber
>>> from scrubber import Scrubber
>>> scrubber = Scrubber(autolink=True)
>>> scrubber.scrub("<script>alert('foo');</script><p>bar, www.google.com</p>")
u'<p>bar, <a href="http://www.google.com" rel="nofollow">www.google.com</a></p>'
>>>