0

I'm using JsonLinesItemExporter to export some data and instead of

{"name": "Color TV", "price": "1200"}
{"name": "DVD player", "price": "200"}

scrapy is writing the following to file:

{"name": ["Color TV"], "price": ["1200"]}
{"name": ["DVD player"], "price": ["200"]}

(From debug) it seems I'm passing a correct value (not a list) and that both item.add_value and item.replace_value are replacing my strings by a single string element list.

Is this configurable? If not, how to get a different behaviour? Extend JsonLinesItemExporter or is there a better approach?

4

1 回答 1

2

您确定您使用的是正确配置的 ItemLoader 吗?我建议使用TakeFirst(此处的文档:https ://docs.scrapy.org/en/latest/topics/loaders.html )

使用示例:

class YourItemLoader(ItemLoader):
    default_output_processor = TakeFirst()
于 2019-06-20T13:34:42.787 回答