第十八節:Scrapy爬蟲框架之settings文件詳解
阿新 • • 發佈:2019-04-15
system tle 下載 cati 項目 spi 設置 com 服務器
# -*- 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‘
第十八節:Scrapy爬蟲框架之settings文件詳解