cra草的自定义设置

一月

使用scrapy,我有一只蜘蛛:

class IndexSpider(scrapy.Spider):
    name = "indices"

    def __init__(self, *args, **kwargs):
        super(IndexSpider, self).__init__(*args, **kwargs)

        # set custom settings
        custom_settings = {
            'DOWNLOAD_DELAY': 2,
            'ITEM_PIPELINES': {
                'freedom.pipelines.IndexPipeline': 300
            }
        }

但是,当我稍后尝试通过以下方式访问设置时

    print(dict(self.settings.get('ITEM_PIPELINES')))

他们是空的。背景是我想基于每个蜘蛛控制设置(和可能的管道)。
我在这里做错了什么?

瓦尔迪尔·史丹姆

custom_settings 应该是一个类属性:

class IndexSpider(scrapy.Spider):
    name = "indices"

    # set custom settings
    custom_settings = {
        'DOWNLOAD_DELAY': 2,
        'ITEM_PIPELINES': {
            'freedom.pipelines.IndexPipeline': 300
        }
    }

    def __init__(self, *args, **kwargs):
        super(IndexSpider, self).__init__(*args, **kwargs)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章