AssertionError: ElementTree not initialized, missing root

Hi, Why the crash? I am thinking about that it must be related with the web site which i am parsing. Please point me in the right direction. Regards. (lxml-2.3 on Python 2.5.2) The code: #-*- coding: utf-8 -*- #!/usr/bin/env python import lxml.html root = "http://www.forumla.net" r = lxml.html.parse(root) title = r.find(".//title").text print title The traceback File "ll.py", line 8, in <module> title = r.find(".//title").text File "lxml.etree.pyx", line 1936, in lxml.etree._ElementTree.find (src/lxml/lxml.etree.c:44987) File "lxml.etree.pyx", line 1698, in lxml.etree._ElementTree._assertHasRoot (src/lxml/lxml.etree.c:42865) AssertionError: ElementTree not initialized, missing root

On 04/09/2011 07:41 AM, Baþar ÖZDEMÝR wrote:
Hi, Why the crash? I am thinking about that it must be related with the web site which i am parsing. Please point me in the right direction. Regards. (lxml-2.3 on Python 2.5.2)
The code:
#-*- coding: utf-8 -*- #!/usr/bin/env python import lxml.html
root = "http://www.forumla.net"
r = lxml.html.parse(root) title = r.find(".//title").text
print title
The traceback
File "ll.py", line 8, in <module> title = r.find(".//title").text File "lxml.etree.pyx", line 1936, in lxml.etree._ElementTree.find (src/lxml/lxml.etree.c:44987) File "lxml.etree.pyx", line 1698, in lxml.etree._ElementTree._assertHasRoot (src/lxml/lxml.etree.c:42865) AssertionError: ElementTree not initialized, missing root
Try this: title = r.getroot().find(".//title").text Bob Kline
participants (2)
-
Baþar ÖZDEMÝR
-
Bob Kline