Extending lxml.html.HtmlElement object

Asked by At

I am trying to extend the functionality of lxml.html.HtmlElement but without success. Prototype of my class will look like this

class HtmlTree(HtmlElement):

   encoding = None

   def from_body(html_body, encoding, base_url):
      tree = html.fromstring(

      o = cls()
      o.encoding = encoding

   # I do not know how to move tree into my object

   def tostring(self):
      html.tostring(self, encoding=self.encoding)

Any ideas how to do it properly?

0 Answers