settings中的配置
DUPEFILTER_CLASS = “scrapy_redis.dupefilter.RFPDupeFilter”
SCHEDULER = “scrapy_redis.scheduler.Scheduler”
SCHEDULER_PERSIST = True
REDIS_HOST=‘192.168.72.137’
REDIS_PORT=6379
REDIS_PASSWORD=’’
spider中配置
。。。
。。。
。。。
from scrapy_redis.spiders import RedisCrawlSpider
class MypeopleSpider(RedisCrawlSpider):
name = ‘mypeople’
allowed_domains = [‘people.com.cn’]
# start_urls = [‘http://politics.people.com.cn/GB/1024/index1.html’]
redis_key = “mypeople:start_url”
rules = (Rule( Extractor(allow=(\"index(\\d+).html\")), callback=\"get_parse\", follow=True),)
def get_parse(self, response):
pass
scrapy-redis配置解释
SCHEDULER=“scrapy_redis.scheduler.Scheduler”
DUPEFILTER=“scrapy_redis.dupefilter.RFPDupeFilter”
# 链接redis
REDIS_HOST=‘192.168.72.137’
REDIS_PORT=6379
REDIS_PASSWORD=’’
#配置队列可以不写默认或是写三个中的一个
# SCHEDULER_QUEUE_CLASS=‘scrapy_redis.queue.PriorityQueue’
# SCHEDULER_QUEUE_CLASS=‘scrapy_redis.queue.FifoQueue’
SCHEDULER_QUEUE_CLASS=‘scrapy_redis.queue.LifoQueue’
#持久化配置 使用True的时候就是指纹队列爬取后不会清空否则自动清空默认是False
SCHEDULER_PERSIST=True
# 重爬配置 默认为False 如果持久配置为True那么中断再启动 爬虫队列和指纹队列 都不会清空 True时候会清空连续不上
# SCHEDULER_FLUSH_ON_START=True
# PIPELINE配置 默认不启动 启动的话 会把item存到redis中
# ITEM_PIPELINES={
# ‘scrapy_redis.pipelines.RedisPipeline’:300
# }
配置数据库存储
MONGO_URI=‘mongodb://admin:admin123@127.0.0.1:27017’
继续阅读与本文标签相同的文章
下一篇 :
WPS⁺云办公如何进行文档修复
-
如何1秒在Word中输入10000+个字?这个功能太强大了!
2026-05-18栏目: 教程
-
三星胜诉!韩专利审判院裁定瑞士龙沙公司专利无效
2026-05-18栏目: 教程
-
随着人类文明的进步科技的发展,技术驱动的顶级问题慢慢浮现!
2026-05-18栏目: 教程
-
GitHub最强技术面试手册:Tech Interview Handbook
2026-05-18栏目: 教程
-
阿里云ACP认证考试须知+心得(精)
2026-05-18栏目: 教程
