我无法使用 python scrapy 从管道打印抓取的值。
在我的 python scrapy 代码中,我正在为项目容器生成值,这些项目值需要存储在管道中并返回值。但它给我带来了类型错误。你能帮我一下吗?
管道.py
class JnjwcpocPipeline(object):
def process_item(self, item, spider):
print("Pipeline :" + item['product_item'][0])
return item
产品线:强生婴儿香皂
ERROR: Error processing {'product_item': None, 'wprice_item': None} Traceback (most recent call last):
current.result = callback(current.result, *args, **kw) print("Pipeline :" + item['product_item'][0])TypeError: 'NoneType' object is not subscriptable
请您参考如下方法:
item['product_item'] 好像是None,所以item['product_item'][0] 是不可调用的,试试使它不是 None 而是一个容器并对其进行测试。
如果这是问题所在,您可以使用一些 if 来检查它是否为 None
