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

相关文章:

  • 2021-06-21
  • 2021-08-20
  • 2022-02-23
  • 2021-10-06
  • 2022-01-11
  • 2021-07-22
  • 2022-02-17
  • 2021-05-23
猜你喜欢
  • 2022-12-23
  • 2021-11-16
  • 2021-04-06
  • 2022-12-23
  • 2022-12-23
  • 2021-10-14
  • 2021-07-10
相关资源
相似解决方案