I am facing some difficulty in scraping data with lxml.
The code snippet is:
from lxml import etree
parser = etree.HTMLParser()
f = open("test1.html", "r")
content = f.read()
tree = etree.fromstring(content, parser)
print tree.xpath('//table[@id="table_search_results"]/tbody/tr')
And my html snippet is:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" class=" gecko ff3 linux js gecko ff3 linux js">
............
............
<table cellspacing="0" cellpadding="0" border="0" height="100" id="table_search_results"><tbody><tr></tr></tbody></table> </html>
But I am unable to get the table data from my python code. The print statement is showing null, whereas clearly I have the table element with the given id.
Please help.