zoukankan      html  css  js  c++  java
  • 第十八节:Scrapy爬虫框架之settings文件详解

    # -*- coding: utf-8 -*-

    # Scrapy settings for maoyan project
    #
    # For simplicity, this file contains only settings considered important or
    # commonly used. You can find more settings consulting the documentation:
    #
    # https://doc.scrapy.org/en/latest/topics/settings.html
    # https://doc.scrapy.org/en/latest/topics/downloader-middleware.html
    # https://doc.scrapy.org/en/latest/topics/spider-middleware.html

    # #Scrapy项目的名字,这将用来构造默认 User-Agent
    BOT_NAME = 'BLZX'

    SPIDER_MODULES = ['BLZX.spiders'] # Scrapy搜索spider的模块列表 默认: [xxx.spiders]
    NEWSPIDER_MODULE = 'BLZX.spiders' # 使用 genspider 命令创建新spider的模块。默认: 'xxx.spiders'

    # 通过在用户代理上标识您自己(和您的网站)来负责地爬行
    # Crawl responsibly by identifying yourself (and your website) on the user-agent
    #USER_AGENT = 'maoyan (+http://www.yourdomain.com)'

    # Obey robots.txt rules 遵守robots.txt规则
    ROBOTSTXT_OBEY = False

    # 配置Scrapy执行的最大并发请求(默认值:16)
    # Configure maximum concurrent requests performed by Scrapy (default: 16)
    #CONCURRENT_REQUESTS = 32

    # 同一网站的请求配置延迟(默认值:0)
    # Configure a delay for requests for the same website (default: 0)
    # See https://doc.scrapy.org/en/latest/topics/settings.html#download-delay
    # See also autothrottle settings and docs
    # 下载延迟
    #DOWNLOAD_DELAY = 3

    # 下载延迟设置将仅满足以下条件之一(二选一)
    # The download delay setting will honor only one of:
    #CONCURRENT_REQUESTS_PER_DOMAIN = 16 # 每个域的并发请求的最大值
    #CONCURRENT_REQUESTS_PER_IP = 16 # 对单个IP进行并发请求的最大值

    # 禁用cookie(默认情况下启用)
    # Disable cookies (enabled by default)
    #COOKIES_ENABLED = False

    # 禁用telnet控制台(默认启用)
    # Disable Telnet Console (enabled by default)
    #TELNETCONSOLE_ENABLED = False

    # 覆盖默认请求头
    # Override the default request headers:
    #DEFAULT_REQUEST_HEADERS = {
    # 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
    # 'Accept-Language': 'en',
    #}

    # 启用或禁用蜘蛛中间件
    # Enable or disable spider middlewares
    # See https://doc.scrapy.org/en/latest/topics/spider-middleware.html

    # =======================Spider Middleware=============================
    #SPIDER_MIDDLEWARES = {
    # 'maoyan.middlewares.MaoyanSpiderMiddleware': 543,
    #}


    # 启用或禁用下载器中间件
    # Enable or disable downloader middlewares
    # See https://doc.scrapy.org/en/latest/topics/downloader-middleware.html

    # =====================Downloader Middleware===========================
    # DOWNLOADER_MIDDLEWARES = {
    # 'maoyan.middlewares.MaoyanDownloaderMiddleware': 543,
    # }

    # 启用或禁用扩展
    # Enable or disable extensions
    # See https://doc.scrapy.org/en/latest/topics/extensions.html
    #EXTENSIONS = {
    # 'scrapy.extensions.telnet.TelnetConsole': None,
    #}

    # 管道配置项目
    # Configure item pipelines
    # See https://doc.scrapy.org/en/latest/topics/item-pipeline.html
    #ITEM_PIPELINES = {
    # 'maoyan.pipelines.MaoyanPipeline': 300,
    #}

    # 启用和配置AutoThrottle扩展(默认情况下禁用)
    # Enable and configure the AutoThrottle extension (disabled by default)
    # See https://doc.scrapy.org/en/latest/topics/autothrottle.html
    #AUTOTHROTTLE_ENABLED = True

    # 初始下载延迟
    # The initial download delay
    #AUTOTHROTTLE_START_DELAY = 5

    # 在高延迟情况下设置的最大下载延迟
    # The maximum download delay to be set in case of high latencies
    #AUTOTHROTTLE_MAX_DELAY = 60

    # Scrapy平均请求数应与每个远程服务器并行发送
    # The average number of requests Scrapy should be sending in parallel to
    # each remote server
    #AUTOTHROTTLE_TARGET_CONCURRENCY = 1.0
    # Enable showing throttling stats for every response received:
    #AUTOTHROTTLE_DEBUG = False

    # 启用和配置HTTP缓存(默认情况下禁用)
    # Enable and configure HTTP caching (disabled by default)
    # See https://doc.scrapy.org/en/latest/topics/downloader-middleware.html#httpcache-middleware-settings
    #HTTPCACHE_ENABLED = True
    #HTTPCACHE_EXPIRATION_SECS = 0
    #HTTPCACHE_DIR = 'httpcache'
    #HTTPCACHE_IGNORE_HTTP_CODES = []
    #HTTPCACHE_STORAGE = 'scrapy.extensions.httpcache.FilesystemCacheStorage'




  • 相关阅读:
    web架构
    网站开发的学习交流 系统架构 负载均衡
    数据库连接
    OpenCV4【12】边缘检测
    python基础_格式化输出(%用法和format用法)
    Python之telnetlib模块
    根据文字或图片来生成用于Banner输出的字符画
    Python3 range() 函数用法
    Python psutil cpu_percent调用说明
    @staticmethod和@classmethod的用法
  • 原文地址:https://www.cnblogs.com/zhaco/p/10615553.html
Copyright © 2011-2022 走看看