Scrapy_settings.py

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

# Scrapy settings for aaaaa 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,同时也用来log,当您使用 startproject 命令创建项目时其也被自动赋值。
'''
BOT_NAME = 'aaaaa'
'''
#Scrapy搜索spider的模块列表 默认: [xxx.spiders]
'''
SPIDER_MODULES = ['aaaaa.spiders']
'''
#使用 genspider 命令创建新spider的模块。默认: 'xxx.spiders'
'''
NEWSPIDER_MODULE = 'aaaaa.spiders'

'''
#爬取的默认User-Agent,除非被覆盖
'''
# Crawl responsibly by identifying yourself (and your website) on the user-agent
#USER_AGENT = 'aaaaa (+http://www.yourdomain.com)'

'''
是否准守ROBOTS协议,默认为True
'''
# Obey robots.txt rules
ROBOTSTXT_OBEY = True
'''
#Scrapy downloader 并发请求(concurrent requests)的最大值,默认: 16
'''
# Configure maximum concurrent requests performed by Scrapy (default: 16)
#CONCURRENT_REQUESTS = 32

# 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与CONCURRENT_REQUESTS_PER_IP只有一个会生效
对单个网站进行并发请求的最大值。
'''
#CONCURRENT_REQUESTS_PER_DOMAIN = 16
'''
对单个IP进行并发请求的最大值。
'''
#CONCURRENT_REQUESTS_PER_IP = 16
'''
禁用Cookie(默认情况下启用)
'''
# Disable cookies (enabled by default)
#COOKIES_ENABLED = False
'''
#禁用Telnet控制台(默认启用)
'''
# Disable Telnet Console (enabled by default)
#TELNETCONSOLE_ENABLED = False

'''
#覆盖默认请求标头,一般不放开,在download中间键里设置即可
'''
# 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',
#}

'''
是否启用SPIDER_MIDDLEWARES
'''
# Enable or disable spider middlewares
# See https://doc.scrapy.org/en/latest/topics/spider-middleware.html
#SPIDER_MIDDLEWARES = {
#    'aaaaa.middlewares.AaaaaSpiderMiddleware': 543,
#}

'''
是否启用DOWNLOADER_MIDDLEWARES
'''
# Enable or disable downloader middlewares
# See https://doc.scrapy.org/en/latest/topics/downloader-middleware.html
#DOWNLOADER_MIDDLEWARES = {
#    'aaaaa.middlewares.AaaaaDownloaderMiddleware': 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 = {
#    'aaaaa.pipelines.AaaaaPipeline': 300,
#}

# Enable and configure the AutoThrottle extension (disabled by default)
# See https://doc.scrapy.org/en/latest/topics/autothrottle.html
#启用和配置AutoThrottle扩展(默认情况下禁用)
#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'

猜你喜欢

转载自blog.csdn.net/rookie_is_me/article/details/85258389