I need to sanitize HTML submitted by the user by closing any open tags with correct nesting order. I have been looking for an algorithm or Python code to do this but haven\'
I tried to use, below method but Failed on python 3
from BeautifulSoup import BeautifulSoup soup = BeautifulSoup(page, 'html5lib')
I tried below and got Success
soup = bs4.BeautifulSoup(html, 'html5lib') f_html = soup.prettify() print(f'Formatted html::: {f_html}')