from stripogram import html2text, html2safehtml
mylumpofdodgyhtml
mylumpofcoolcleancollectedhtml = html2safehtml(mylumpofdodgyhtml,
    valid_tags=('b', 'a', 'i', 'br', 'p'))
Python library for XSS filtering?