I need to store data in Scrapy Item in parts. To update only the information that I found at the moment.
I did it, but the code looks too verbose. Three lines I repeat very often:
price['pricereg'] = pricereg
price['priceprolong'] = priceprolong
price['pricechange'] = pricechange
Is it possible to make the code shorter?
EMPTY_PRICE = {
'pricereg': None,
'priceprolong': None,
'pricechange': None,
}
item['name'] = "some name"
price = item.get('price', EMPTY_PRICE)
price['pricereg'] = pricereg
price['priceprolong'] = priceprolong
item['price'] = price
item['name'] = "some name"
price = item.get('price', EMPTY_PRICE)
price['pricechange'] = pricechange
item['price'] = price