我有一些看起来像截图的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?
答案 0 :(得分:5)
tbody
为generated by the browser ,您无法通过Scrapy下载程序获取它。直接进入tr
元素:
table_row.xpath('.//tr')