Scrapy Settings Import paths and classes

Scrapy 配置

New in version 2.4.0.
When a setting references a callable object to be imported by Scrapy, such as a > class or a function, there are two different ways you can specify that object:

  • As a string containing the import path of that object
  • As the object itself

2.4.0版本之后,scrapy支持两种配置方式

  • 使用import path
  • 使用object
    示例
from mybot.pipelines.validate import ValidateMyItem
ITEM_PIPELINES = {
    # passing the classname...
    ValidateMyItem: 300,
    # ...equals passing the class path
    'mybot.pipelines.validate.ValidateMyItem': 300,
}

更多内容参见: Scrapy Settings

posted @ 2021-09-03 15:03  dmyHero  阅读(28)  评论(0编辑  收藏  举报