這篇文章將為大家詳細(xì)講解有關(guān)scrapy項(xiàng)目中如何配置redis配置文件中的setting參數(shù),文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個參考,希望大家閱讀完這篇文章后對相關(guān)知識有一定的了解。

scrapy項(xiàng)目 setting.py
#Resis 設(shè)置
#使能Redis調(diào)度器
SCHEDULER = 'scrapy_redis.scheduler.Scheduler'
#所有spider通過redis使用同一個去重過濾器
DUPEFILTER_CLASS = 'scrapy_redis.dupefilter.RFPDupeFilter'
#不清除Redis隊(duì)列、這樣可以暫停/恢復(fù) 爬取
#SCHEDULER_PERSIST = True
#SCHEDULER_QUEUE_CLASS ='scrapy_redis.queue.PriorityQueue' #默認(rèn)隊(duì)列,優(yōu)先級隊(duì)列
#備用隊(duì)列。
#SCHEDULER_QUEUE_CLASS ='scrapy_redis.queue.FifoQueue' #先進(jìn)先出隊(duì)列
#SCHEDULER_QUEUE_CLASS ='scrapy_redis.queue.LifoQueue' #后進(jìn)先出隊(duì)列
#較大空閑時間防止分布式爬蟲因?yàn)榈却P(guān)閉
#SCHEDULER_IDLE_BEFORE_CLOSE = 10
#將抓取的item存儲在Redis中以進(jìn)行后續(xù)處理。
ITEM_PIPELINES = {
'scrapy_redis.pipelines.RedisPipeline':300,
}
# The item pipeline serializes and stores the items in this redis key.
#item pipeline 將items 序列化 并用如下key名儲存在redis中
#REDIS_ITEMS_KEY = '%(spider)s:items'
#默認(rèn)的item序列化方法是ScrapyJSONEncoder,你也可以使用自定義的序列化方式
#REDIS_ITEMS_SERIALIZER = 'json.dumps'
#設(shè)置redis地址 端口 密碼
REDIS_HOST = 'localhost'
REDIS_HOST = 6379
#也可以通過下面這種方法設(shè)置redis地址 端口和密碼,一旦設(shè)置了這個,則會覆蓋上面所設(shè)置的REDIS_HOST和REDIS_HOST
REDIS_URL = 'redis://root:redis_pass@xxx.xx.xx.xx:6379'
#root用戶名,redis_pass:你設(shè)置的redis驗(yàn)證密碼,xxxx:你的主機(jī)ip
#你設(shè)置的redis其他參數(shù) Custom redis client parameters (i.e.: socket timeout, etc.)
REDIS_PARAMS = {}
#自定義的redis客戶端類
#REDIS_PARAMS['redis_cls'] = 'myproject.RedisClient'
# If True, it uses redis ``zrevrange`` and ``zremrangebyrank`` operation. You have to use the ``zadd``
# command to add URLS and Scores to redis queue. This could be useful if you
# want to use priority and avoid duplicates in your start urls list.
#REDIS_START_URLS_AS_SET = False
# 默認(rèn)的RedisSpider 或 RedisCrawlSpider start urls key
#REDIS_START_URLS_KEY = '%(name)s:start_urls'
#redis的默認(rèn)encoding是utf-8,如果你想用其他編碼可以進(jìn)行如下設(shè)置:
#REDIS_ENCODING = 'latin1'
標(biāo)題名稱:scrapy項(xiàng)目中如何配置redis配置文件中的setting參數(shù)-創(chuàng)新互聯(lián)
網(wǎng)站地址:http://chinadenli.net/article48/hgjep.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供建站公司、網(wǎng)站改版、用戶體驗(yàn)、靜態(tài)網(wǎng)站、品牌網(wǎng)站設(shè)計(jì)、定制網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容