from bs4 import BeautifulSoup soup = BeautifulSoup(html_content, 'html.parser') print(soup.prettify())