Python 管道使用"raise DropItem"重复检查器,但我们如何让它管道向下?



raise DropItem在下面创建了太多噪音并输出完整的对象

问题:我们如何使它只输出字符串?或者还有其他方法可以将项目放入管道中?

现在的结果是一个完整的对象,它的所有值和混乱的输出。我的愿望是默默地放下一件物品。。。我们以前使用过delete((,但这导致了以后管道中的错误。感谢的帮助

# Duplicate checker based on https://scrapy2.readthedocs.io/en/latest/topics/item-pipeline.html
if item['sku'] in self.skus_seen:
if "url" not in item or not item['url']:
item['url'] = '???, plz store item url in spider'
raise DropItem(f"Duplicate products {item['sku']} at {item['url']}")

大众问答;(

这里有

实施

导入日志记录来自报废的导入日志格式化程序

类PoliteLogFormatter(logformatter.logformatter(:def已删除(self、item、exception、response、spider(:返回{'level':日志记录。信息,'msg':日志格式化程序。DROPPEDMSG,"args":{"exception":异常,"item":项,}}

Scrapy-无声掉落物品

相关内容

最新更新