标签: scrapy-settings

Scrapy:如何从蜘蛛类的 __init__() 方法访问自定义的 CLI 传递设置?

我需要使用以下命令访问从 CLI 传递的自定义设置:

-s SETTING_NAME="SETTING_VAL" 来自蜘蛛类的 __init__() 方法

get_project_settings()允许我仅访问静态设置。

该文档解释了如何通过以下方式从管道设置新管道来访问这些自定义设置:

@classmethod
def from_crawler(cls, crawler):
    settings = crawler.settings
Run Code Online (Sandbox Code Playgroud)

但是有什么方法可以通过__init__()蜘蛛方法访问它们吗?

python scrapy scrapy-pipeline scrapy-settings

2
推荐指数
1
解决办法
1362
查看次数

标签 统计

python ×1

scrapy ×1

scrapy-pipeline ×1

scrapy-settings ×1