Mario Honse
Mario Honse

Reputation: 299

An array field in scrapy.Item

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?

Upvotes: 19

Views: 13207

Answers (1)

backtrack
backtrack

Reputation: 8154

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

Upvotes: 27

Related Questions