Quick reference

You can take a look at the following references to get an overview:

  • Formatted printing: The following method gives the formatted output:
    • soup.prettify(): This method is used to output with indentation and formatting
  • Unformatted printing: These methods give output without any format or indentation:
    • str(soup)
    • soup.encode()
    • soup.decode()
  • Formatters: These methods have the ability to control the behavior of the output:
    • soup.prettify(formatter="minimal")
    • soup.prettify(formatter="html")
    • soup.prettify(formatter="None")
    • soup.prettify(formatter=already_defined_func)
  • get_text(): This method gives you all the content of an object or a tag:
    • soup.get_text(): This method is used to get all the text content in BeautifulSoup or Tag objects

Get Getting Started with Beautiful Soup now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.