Can somebody explain this to me, please?
In my spider, I have code for extracting data using XPath.
price_euro = add.xpath('.//strong[@class="price price--eur"]/text()').extract_first()
print 'price_euro', price_euro, type(price_euro)
and what I get is:
price_euro 25.500 <type 'unicode'>
and I understand this, I have it as a string(Unicode) because I have used .extract_first() and this is what I want.
But in my pipeline,
print "item['price_euro']", item['price_euro'], type(item['price_euro'])
I have it as a list
item['price_euro'] [u'25.500 '] <type 'list'>
This is not the big problem for me, but it is annoying because every time when I want to access it I need to add [0] at end of it. eg. item['price_euro'][0]
Can I disable this and should I?
What is the logic behind this?
Thank you
How I add price_euro
l = ItemLoader(item=MyItem(), response=response)
l.add_value('price_euro', price_euro)
yield l.load_item()