Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to get table rows with Scrapy xpath

Tags:

xpath

scrapy

enter image description here

I have some html that looks like the screenshot. I want to get the table rows. I have:

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

In the command line I tried:

>>> 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]: []

Why am I unable to select the tbody?

like image 950
user1592380 Avatar asked Nov 15 '25 21:11

user1592380


1 Answers

tbody is generated by the browser, you don't get it with Scrapy downloader. Just get straight to the tr elements:

table_row.xpath('.//tr')
like image 175
alecxe Avatar answered Nov 18 '25 18:11

alecxe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!