HTMLDocument and Xpath
swilson at acs.on.ca
swilson at acs.on.ca
Thu Feb 2 20:34:39 EST 2006
Hi, I want to use xpath to scrape info from a website using pyXML but I
keep getting no results.
For example, in the following, I want to return the text "Element1" I
can't get xpath to return anything at all. What's wrong with this
code?
--------------------
from xml.dom.ext.reader import HtmlLib
from xml.xpath import Evaluate
reader = HtmlLib.Reader()
doc_node = reader.fromString("""
<html>
<head>
<title>Python Programming Language</title>
</head>
<body>
<table><tr><td>element1</td></tr></table>
</body>
</html>
""")
test = Evaluate('td', doc_node.documentElement)
print "test =", test
------------
All I get is an empty list for output.
Thx in advance
Shawn
More information about the Python-list
mailing list