1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| >>> class Foo(lxml.html.HtmlElement):
def __init__(self,BodyElement,poids):
super(Foo,self).__init__()
self.poids=poids
self.__dict__.update(BodyElement.__dict__)
>>> a=lxml.html.parse('http://www.google.fr/').getroot().body
>>> a.__dict__
{}
>>> b=Foo(a,56)
>>> a.attrib
{'onload': "document.f.q.focus();if(document.images)new Image().src='/images/nav_logo4.png'", 'marginheight': '3', 'topmargin': '3', 'alink': '#ff0000', 'text': '#000000', 'bgcolor': '#ffffff', 'link': '#0000cc', 'vlink': '#551a8b'}
>>> b.attrib
{} |
Partager