def check_html(html):
 parser = etree.HTMLParser()
 try:
  etree.fromstring(html, parser)
  return True
 except Exception:
  pass
 return False

def check_html ( html ) : parser = etree . HTMLParser ( ) try : etree . fromstring ( html , parser ) return True except Exception : pass return False
check whether the passed in html string can be parsed by lxml .