我在用lxml抓取数据时遇到了一些困难。你知道吗
代码段是:
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')
我的html代码片段是:
<!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>
但是我无法从python代码中获取表数据。print语句显示为null,而我显然拥有具有给定id的table元素
请帮忙。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐