code: def html_to_text(string):
      
      if isinstance(string, six.text_type):
          string = string.encode('utf8')
  
      s = _prepend_utf8_declaration(string)
      s = s.replace(b"\n", b"")
      tree = html_fromstring(s)
  
      if tree is None:
          return None
  
      return html_tree_to_text(tree)
docs: Dead-simple HTML-to-text converter:
          >>> html_to_text("one<br>two<br>three")
          >>> "one\ntwo\nthree"
  
      NOTES:
          1. the string is expected to contain UTF-8 encoded HTML!
          2. returns utf-8 encoded str (not unicode)
          3. if html can't be parsed returns None