An array field in scrapy.Item

2019-06-15 07:34发布

I want to add a field to scrapy.Item so that it's an array:

class MyItem(scrapy.Item):
    field1 = scrapy.Field()
    field2 = scrapy.Field()
    field3_array = ???

How can I do that?

1条回答
放荡不羁爱自由
2楼-- · 2019-06-15 08:22

You just create a filed

field3_array = scrapy.Field()

But while parsing the scraped items do like this

items['field3_array'] = []

items['field3_array'][0] ='one'
items['field3_array'][1] ='two'

in this way you can achieve this.

Have a look

查看更多
登录 后发表回答