示例#1
0
 def fromstring(self, html):
     html = encodeValue(html)
     try:
         self.doc = lxml.html.fromstring(html)
     except:
         html = html.encode('utf-8','replace')
         self.doc = lxml.html.fromstring(html)
     return self.doc
示例#2
0
 def fromstring(self, html):
     html = encodeValue(html)
     try:
         self.doc = lxml.html.fromstring(html)
     except:
         html = html.encode("ascii", "replace")
         self.doc = lxml.html.fromstring(html)
     return self.doc
示例#3
0
 def fromstring(self, html):
     encoding = get_encodings_from_content(html)
     encoding = encoding and encoding[0] or None
     if not encoding:
         html = encodeValue(html)
         self.doc = lxml.html.fromstring(html)
     else:
         html = smart_str(html, encoding=encoding)
         parser = lxml.html.HTMLParser(encoding=encoding)
         self.doc = lxml.html.fromstring(html, parser=parser)
     return self.doc
示例#4
0
 def fromstring(self, html):
     encoding = get_encodings_from_content(html)
     encoding = encoding and encoding[0] or None
     if not encoding:
         html = encodeValue(html)
         self.doc = lxml.html.fromstring(html)
     else:
         html = smart_str(html, encoding=encoding)
         parser = lxml.html.HTMLParser(encoding=encoding)
         self.doc = lxml.html.fromstring(html, parser=parser)
     return self.doc
示例#5
0
 def fromstring(self, html):
     html = encodeValue(html)
     self.doc = lxml.html.fromstring(html)
     return self.doc
示例#6
0
 def fromstring(self, html):
     html = encodeValue(html)
     self.doc = soupparser.fromstring(html)
     return self.doc
示例#7
0
 def fromstring(self, html):
     html = encodeValue(html)
     self.doc = lxml.html.fromstring(html)
     return self.doc
示例#8
0
 def fromstring(self, html):
     from lxml.html import soupparser
     html = encodeValue(html)
     self.doc = soupparser.fromstring(html)
     return self.doc
示例#9
0
 def fromstring(self, html):
     from lxml.html import soupparser
     html = encodeValue(html)
     self.doc = soupparser.fromstring(html)
     return self.doc
示例#10
0
 def fromstring(self, html):
     html = encodeValue(html)
     self.doc = soupparser.fromstring(html)
     return self.doc