I am writing a scraper, using Scrapy, in which I need to populate items with default values at first.
Could my method be improved?
def sp_offer_page(self, response):
item = MallCrawlerItem()
for key, value in self.get_default_item_dict().iteritems():
item[key] = value
item['is_coupon'] = 1
item['mall'] = 'abc'
# some other logic
yield item
def get_default_item_dict(self): # populate item with Default Values
return {'mall': 'null', 'store': 'null', 'bonus': 'null',
'per_action': 0, 'more_than': 0,
'up_to': 0, 'deal_url': 'null', 'category': 'null', 'expiration': 'null', 'discount': 'null',
'is_coupon': 0, 'code': 'null'}