下载
- Reids:https://github.com/MicrosoftArchive/redis
- scrapy-redis:https://github.com/rmax/scrapy-redis
- redis-py:> pip install redis
- python:3.5
将下面设置添加到setting.py
1 SCHEDULER = "scrapy_redis.scheduler.Scheduler" 2 DUPEFILTER_CLASS = "scrapy_redis.dupefilter.RFPDupeFilter" 3 TEM_PIPELINES = { 4 ‘scrapy_redis.pipelines.RedisPipeline‘: 300 5 }
启动
- 在spider.py上设置 name 和 redis_key
- 启动redis-server、redis-cli 和 pycharm,可以看到scapy在等待start_urls
1 2018-02-26 14:07:56 [scrapy.extensions.telnet] DEBUG: Telnet console listening on 127.0.0.1:6023
- 在redis-cli上输入 llpush [redis_key] [start_urls] 启动爬虫
salver机上的配置与master无异,主从连接参考http://www.cnblogs.com/kylinlin/p/5198233.html