right! I have been able !! this is what I wanted. Thanks ¡¡¡

El miércoles, 8 de enero de 2014 10:12:57 UTC+1, Paul Tremberth escribió:
>
> Hi,
> you should be able to do
>
> print item.get('tric', 0)
>
>
> /Paul.
>
> On Wednesday, January 8, 2014 1:49:50 AM UTC+1, Roberto López wrote:
>>
>> I will try to explain the best way:
>>
>> To load a value in loader I use the following code: 
>> rLoader.add_value('tric',HTML.xpath('.//table[@class="resultTotal"]/tr/td[6]').re(r'\xa3(\d+\.\d+)'))
>>  
>> It´s ok, the code work fine. The values between td tags are loaded in the 
>> loader, <td>11.8</td>.
>> Sometimes, between <td> tags there isn't a numeric value, for example two 
>> dashes <td>--</td>. In this case, as expected, nothing it's loaded, it's 
>> ok. 
>> When I try to print item[tric] an error occurs: exceptions.KeyError: 
>> 'tric'.
>> However the tric attribute exists in item definition. 
>>
>> How can I fix it the right way? I would like print item[tric] and get 0 
>> value or null.
>>
>>

-- 
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/groups/opt_out.

Reply via email to