Scrapy_setting

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

# Scrapy settings for quanshubook 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

BOT_NAME = 'quanshubook'

SPIDER_MODULES = ['quanshubook.spiders']
NEWSPIDER_MODULE = 'quanshubook.spiders'

''' 设置模拟浏览器加载'''
# Crawl responsibly by identifying yourself (and your website) on the user-agent
#USER_AGENT = 'quanshubook (+http://www.yourdomain.com)'

'''是否遵循robot协议'''
# Obey robots.txt rules
ROBOTSTXT_OBEY = False

'''最大并发数量# 默认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

'''下载延时 默认为0'''
DOWNLOAD_DELAY = 1

# The download delay setting will honor only one of:
'''在每个域下允许的并发数 默认为8'''
#CONCURRENT_REQUESTS_PER_DOMAIN = 16

'''针对每个ip,允许发起请求的并发数量  默认为0'''
#CONCURRENT_REQUESTS_PER_IP = 16
'''不为零的情况下IP优先级比DOMAIN优先级要高'''
'''DOWNLOAD_DEALY的下载延时就针对于ip而不是网站了'''

# Disable cookies (enabled by default)

"""携带cookie"""
'''是否携带cookies 默认为True,表示携带cookie'''
COOKIES_ENABLED = False
'''默认为False,表示不追踪cookies'''
COOKIE_DEBUG = True


# 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',
    'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 BIDUBrowser/8.7 Safari/537.36',
}

'''中间件'''
# Enable or disable spider middlewares
# See https://doc.scrapy.org/en/latest/topics/spider-middleware.html

'''爬虫中间件'''
#SPIDER_MIDDLEWARES = {
#    'quanshubook.middlewares.QuanshubookSpiderMiddleware': 543,
#}

'''下载中间件(数字是优先级,越小优先级越高)'''
# Enable or disable downloader middlewares
# See https://doc.scrapy.org/en/latest/topics/downloader-middleware.html
DOWNLOADER_MIDDLEWARES = {
    'quanshubook.middlewares.QidinaUserAgentDownloadmiddlerware': 543,
    'quanshubook.middlewares.QidianProxyDowoloadmiddleware':542,
    'quanshubook.middlewares.SeleiniumDoenloadMiddlerWare':544,
}

'''拓展'''
# 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 = {
   'quanshubook.pipelines.QuanshubookPipeline': 300,
}

'''动态设置的下载延时'''
# 默认情况下是关闭的
# 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
'''初始下载延时(为5s)'''
#AUTOTHROTTLE_START_DELAY = 5
# The maximum download delay to be set in case of high latencies
'''最大下载延时'''
#AUTOTHROTTLE_MAX_DELAY = 60
# 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:
'''是否开启debug模式(默认为TRUE)'''
#AUTOTHROTTLE_DEBUG = False

# Enable and configure HTTP caching (disabled by default)
# See https://doc.scrapy.org/en/latest/topics/downloader-middleware.html#httpcache-middleware-settings

'''缓存的拓展,(默认情况下关闭,False)'''
#HTTPCACHE_ENABLED = True
'''设置缓存时间'''
#HTTPCACHE_EXPIRATION_SECS = 0
'''设置缓存保存的路径'''
#HTTPCACHE_DIR = 'httpcache'
'''忽略的响应状态码'''
#HTTPCACHE_IGNORE_HTTP_CODES = []
'''缓存的一个储存插件'''
#HTTPCACHE_STORAGE = 'scrapy.extensions.httpcache.FilesystemCacheStorage'


# # 春花秋月何时了,往事知多少
# 将log日志信息,保存到本地文件
LOG_FILE = 'qd_log_file.log'

# 编码

LOG_ENCODING = 'utf-8'
# #开关
# CRITICAL - 严重错误(critical)
# - ERROR - 一般错误(regular errors)
# - WARNING - 警告信息(warning messages)
# - INFO - 一般信息(informational messages)
# - DEBUG - 调试信息(debugging messages)
LOG_LEVEL ='INFO'




'''其他自定义'''
'''
    调用时,
        属性 = crawler.settings['简直对']

'''

'''mongo'''
MONGO_HOST = '127.0.0.1'
MONGO_POST = 27017
MONGO_DBNAME = 'qd_book'


'''UA池'''
USER_AGENT = [
    "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 2.0.50727; Media Center PC 6.0)",
    "Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 1.0.3705; .NET CLR 1.1.4322)",
    "Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.2; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.0.04506.30)",
    "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN) AppleWebKit/523.15 (KHTML, like Gecko, Safari/419.3) Arora/0.3 (Change: 287 c9dfb30)",
    "Mozilla/5.0 (X11; U; Linux; en-US) AppleWebKit/527+ (KHTML, like Gecko, Safari/419.3) Arora/0.6",
]

'''代理池'''
PROXIES = [
    {'ip_port': '111.8.60.9:8123', 'user_pwd': 'user1:pass1'},
    {'ip_port': '101.71.27.120:80', 'user_pwd': 'user2:pass2'},
    {'ip_port': '122.96.59.104:80', 'user_pwd': None},
    {'ip_port': '122.224.249.122:8088', 'user_pwd': None},
]

'''COOKIES池'''
COOKIES = [

]



常用的
'''是否遵循robot协议'''
# Obey robots.txt rules
ROBOTSTXT_OBEY = False


# 请求头的设置
DEFAULT_REQUEST_HEADERS = {
#   'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
#   'Accept-Language': 'en',
    'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 BIDUBrowser/8.7 Safari/537.36',
}

'''下载延时 默认为0'''
DOWNLOAD_DELAY = 1

# 管道激活
ITEM_PIPELINES = {
   'quanshubook.pipelines.QuanshubookPipeline': 300,
}
# 中间件激活
# 

你可能感兴趣的:(Scrapy_setting)