首页 > 其他 > 详细

Scrapy Settings Import paths and classes

时间:2021-09-04 04:13:19      阅读:35      评论:0      收藏:0      [点我收藏+]

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

Scrapy Settings Import paths and classes

原文:https://www.cnblogs.com/rain-chenwei/p/15223147.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!