def fromstring(cls, html): encoding = get_encodings_from_content(html) encoding = encoding and encoding[0] or None if not encoding: html = encodeValue(html) doc = lxml.html.fromstring(html) else: html = smart_str(html, encoding=encoding) parser = lxml.html.HTMLParser(encoding=encoding) doc = lxml.html.fromstring(html, parser=parser) return doc
def stringToNode(cls, html): html = encodeValue(html) return lxml.html.fromstring(html)
def fromstring(cls, html): html = encodeValue(html) doc = etree.parse(StringIO(html), etree.HTMLParser(recover=True)).getroot() return doc
def fromstring(cls, html): from lxml.html import soupparser html = encodeValue(html) doc = soupparser.fromstring(html) return doc
def fromstring(self, html): from lxml.html import soupparser html = encodeValue(html) self.doc = soupparser.fromstring(html) return self.doc