doc = (
    """<html><head><title>Page title</title></head><body><p id="firstpara" align="center">This is <i>paragraph</i> <a onclick="">one</a>.<p id="secondpara" align="blah">This is <i>paragraph</i> <b>two</b>.</html>"""
    )
soup = BeautifulSoup.BeautifulSoup(doc)
for tag in soup.recursiveChildGenerator():
    if isinstance(tag, BeautifulSoup.Tag) and tag.name in ('a', 'b', 'i'):
        pass
Использование Beautiful Soup для удаления html-тегов из строки