尝试使用Scrapy xpath获取表行

时间:2016-10-19 15:39:43

标签: xpath scrapy

enter image description here

我有一些看起来像截图的html。我想得到表格行。我有:

for table_row in response.selector.xpath("//*[@id = 'ctl00_ContentPlaceHolder1_CaseDetailParties1_gvParties']"):
    print table_row

在命令行中我试过:

>>> table_row
Out[5]: <Selector xpath="//*[@id = 'ctl00_ContentPlaceHolder1_CaseDetailParties1_gvParties']" data=u'<table class="ParamText" cellspacing="0"'>
>>> table_row.xpath('/tbody')
Out[6]: []
>>> table_row.xpath('//tbody')
Out[7]: []

为什么我无法选择tbody?

1 个答案:

答案 0 :(得分:5)

tbodygenerated by the browser ,您无法通过Scrapy下载程序获取它。直接进入tr元素:

table_row.xpath('.//tr')