对上一篇中settings.py中的一些操作的解释

如下是在一个 scrapy-redis爬虫应用模板中的一个,并进行了注解,具体如下

# Scrapy settings for example project
#
# For simplicity, this file contains only the most important settings by
# default. All the other settings are documented here:
#
#     http://doc.scrapy.org/topics/settings.html
#
SPIDER_MODULES = ['example.spiders']
NEWSPIDER_MODULE = 'example.spiders'

USER_AGENT = 'scrapy-redis (+https://github.com/rolando/scrapy-redis)'
# 使用scrapy redis的去重类 不适用scrapy默认的去重类
DUPEFILTER_CLASS = "scrapy_redis.dupefilter.RFPDupeFilter"
# 使用scrapy__redis的调度器,不适用scrapy默认的调度器
SCHEDULER = "scrapy_redis.scheduler.Scheduler"
# 控制爬虫是否允许暂停
SCHEDULER_PERSIST = True
# 队列形式 先进先出  哪个请求先放入到请求队列 哪个请求就先执行
#SCHEDULER_QUEUE_CLASS = "scrapy_redis.queue.SpiderPriorityQueue"
# 栈形式 先进后出
#SCHEDULER_QUEUE_CLASS = "scrapy_redis.queue.SpiderQueue"

#SCHEDULER_QUEUE_CLASS = "scrapy_redis.queue.SpiderStack"

ITEM_PIPELINES = {
    'example.pipelines.ExamplePipeline': 300,
    # 使用redis数据库所要添加的管道,如果使用redis数据库 必须添加
    'scrapy_redis.pipelines.RedisPipeline': 400,
}
# log 日志 level 等级
# debug 调试
LOG_LEVEL = 'DEBUG'

# Introduce an artifical delay to make use of parallelism. to speed up the
# crawl.
# 为了限制爬虫速度
DOWNLOAD_DELAY = 1

猜你喜欢

转载自blog.csdn.net/weixin_42539547/article/details/81710374