scrapy.Item 中的数组字段 [英] An array field in scrapy.Item

查看:87
本文介绍了scrapy.Item 中的数组字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想向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 = ???

我该怎么做?

推荐答案

您只需创建一个归档

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.

看看看看

这篇关于scrapy.Item 中的数组字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆