Scrapy: Default values for items & fields. What is the best implementation?

后端 未结 2 575
臣服心动
臣服心动 2021-01-18 12:06

As far as I could find out from the documentation and various discussions on the net, the ability to add default values to fields in a scrapy item has been removed.

2条回答
  •  清歌不尽
    2021-01-18 12:35

    figured out what the problem was. the pipeline is working (code follows for other people's reference). my problem was, that I am appending values to a field. and I wanted the default method work on one of these listvalues... chose a different way and it works. I am now implementing it with a custom setDefault processor method.

    class DefaultItemPipeline(object):
    
    def process_item(self, item, spider):
        item.setdefault('amz_VendorsShippingDurationFrom', 'default')
        item.setdefault('amz_VendorsShippingDurationTo', 'default')
        # ...
        return item
    

提交回复
热议问题