想想就不从scrapy流程图去写了毕竟是记录,详细可读文档scrapy0.24中文文档
从学习的角度我认为从setting配置开始你会了解其他组件的功能以及设置,当然不涉及源码
首先了所谓的配置并不是只是写在setting这个文件里,同时在配置方法有优先级顺序:
命令行选项(Command line Options)(最高优先级)#终端设定
##可以使用command line 选项 -s (或 --set) 来覆盖一个(或更多)选项 #scrapy crawl myspider -s LOG_FILE=scrapy.log#设置log
爬虫中设定
#使用属性custom_settings覆盖项目的class DemoSpider(scrapy.Spider) : name = 'demo' custom_settings = { 'SOME_SETTING': 'some value', }
项目设定模块(Project settings module)#就是setting文件
获取通过:项目名.settings命令默认设定(Default settings per-command)#自定义配置
from scrapy.commands import ScrapyCommand class Command(ScrapyCommand): default_settings = { 'LOG_ENABLED': False} def run(self, args, opts): print("hello")
默认全局设定(Default global settings)#导模块设置
scrapy.settings.default_settings
如何访问设定:
1.爬虫中通过爬虫基类的属性setting就可以、