I got it working. I tried .//td before and it didn't appear to work. It 
looks like I messed up when debugging and got false negatives. I am now 
able run cell_count = len(row.xpath('td')) and get a cell count like I 
expect. Thanks alot!

On Tuesday, November 25, 2014 11:26:05 AM UTC-6, Rocío Aramberri wrote:
>
> Hi Kamegami,
>
> Try using: 
>
> rows = hxs.xpath('//table[@class="t1"]//tr')for row in rows:
>     cells = row.xpath('.//td').extract()
>
>
> Hope this helps,
> Rocio
>
> 2014-11-25 15:10 GMT-02:00 Kamegami <[email protected] <javascript:>>:
>
>> I have already submitted a Stackoverflow question (
>> https://stackoverflow.com/questions/27115336/issues-looping-over-a-table-in-scrapy)
>>  
>> but I thought I'd ask here as well. I have a confusing situation with how 
>> to loop a selector. The gist of my code is this.
>>
>> rows = hxs.xpath('//table[@class="t1"]//tr')for row in rows:
>>     cells = row.xpath('td').extract()
>>
>> I grab a list of table rows, loop over that and get a list of row cells. The 
>> preceding code does not work, I get a blank list. However, if instead of 
>> looping over the selector I pick a selector from the SelectorList using an 
>> index, it works no problem.
>>
>> rows = hxs.xpath('//table[@class="t1"]//tr')
>> cells = rows[1].xpath('td').extract() #this works
>>
>> So what am I doing wrong? I followed the docs section on Nested selectors 
>> and that didn't help. There should be no difference between looping a 
>> selector and indexing it.
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "scrapy-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> Visit this group at http://groups.google.com/group/scrapy-users.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Rocío Aramberri
>  

-- 
You received this message because you are subscribed to the Google Groups 
"scrapy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/scrapy-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to