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.rea der import HtmlLib
from xml.xpath import Evaluate
reader = HtmlLib.Reader( )
doc_node = reader.fromStri ng("""
<html>
<head>
<title>Python Programming Language</title>
</head>
<body>
<table><tr><td> element1</td></tr></table>
</body>
</html>
""")
test = Evaluate('td', doc_node.docume ntElement)
print "test =", test
------------
All I get is an empty list for output.
Thx in advance
Shawn
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.rea der import HtmlLib
from xml.xpath import Evaluate
reader = HtmlLib.Reader( )
doc_node = reader.fromStri ng("""
<html>
<head>
<title>Python Programming Language</title>
</head>
<body>
<table><tr><td> element1</td></tr></table>
</body>
</html>
""")
test = Evaluate('td', doc_node.docume ntElement)
print "test =", test
------------
All I get is an empty list for output.
Thx in advance
Shawn
Comment