以前,访问 CsvItemExporter
的子类中的设置,我需要修改设置中指定的分隔符,可以使用:
from scrapy.conf import settings
但是该方法现在已贬值:
ScrapyDeprecationWarning: Module
scrapy.conf
is deprecated, usecrawler.settings
attribute instead from scrapy.conf import settings
我现在该怎么做?常用的from_crawler
,“from_settings
类方法在CsvItemExporter
中不起作用。
最佳答案
目前无法使用附加参数扩展提要导出器。事实上,存在一个功能请求要求它:[Enhancement] Allow BaseItemExporter to accept arguments #973
还有 2 个关于允许自定义 CSV 分隔符的功能请求:
CsvItemExporter delimiter should be changeable through settings.py #3252
Adding delimiter, quotechar, encoding, lineterminator options to the CSV exporter #3486
因此,我建议您跟踪这些请求,考虑为它们投票(即添加一个竖起大拇指的 react )或以其他方式提供反馈,与此同时,您可以忽略警告、禁止警告,或者使用 nyov’s approach。 .
关于python - CsvItemExporter 子类中的 Scrapy 1.0+ 正确设置访问?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32911906/