Can someone explain why the first call to root.cssselect() works, while the second fails?
from lxml.html import fromstring
from lxml import etree
html='<html><a href="http://example.com">example</a></html'
root = fromstring(html)
print 'via fromstring', repr(root) # via fromstring <Element html at 0x...>
print root.cssselect("a")
root2 = etree.HTML(html)
print 'via etree.HTML()', repr(root2) # via etree.HTML() <Element html at 0x...>
root2.cssselect("a") # --> Exception
I get:
Traceback (most recent call last):
File "/home/foo_eins_d/src/foo.py", line 11, in <module>
root2.cssselect("a")
AttributeError: 'lxml.etree._Element' object has no attribute 'cssselect'
Version: lxml==3.4.4