bs4.BeautifulSoup.encode_contents

BeautifulSoup.encode_contents(indent_level=None, encoding='utf-8', formatter='minimal')

Renders the contents of this tag as a bytestring.

Parameters:
  • indent_level – Each line of the rendering will be indented this many spaces.
  • eventual_encoding – The bytestring will be in this encoding.
  • formatter – The output formatter responsible for converting entities to Unicode characters.