scrapy-redis的安装部署步骤讲解
先说下自己的环境,redis是部署在centos上的,爬虫运行在windows上,
1. 安装redis
yum install -y redis
2. 修改配置文件
vi /etc/redis.conf
将 protected-mode no解注释,否则的话,在不设置密码情况下远程无法连接redis
3. 重启redis
systemctl restart redis
4. 关闭防火墙
systemctl stop firewalld.service
5. 开始创建scrapy-redis的相关,和普通的scrapy一样的创建,只不过修改setting.py文件,添加一行
REDIS_URL = 'redis://192.168.61.130:6379'
6. 修改spiders.py文件
# -*- coding: utf-8 -*- from scrapy_redis.spiders import RedisSpider class ExampleSpider(RedisSpider): name = 'myspider' redis_key = 'test_key' allowed_domains = ['www.example.com'] def parse(self, response): print(1111) pass
7. 可以执行这个爬虫了
scrapy runspider example.py
8. 进入redis
redis-cli -h 127.0.0.1 -p rpush test_key http://test.com
即可看到爬虫开始运行了
相关推荐
王道革 2020-11-25
wangdonghello 2020-11-03
Langeldep 2020-11-16
chenhualong0 2020-11-16
聚合室 2020-11-16
koushr 2020-11-12
MRFENGG 2020-11-11
guoyanga 2020-11-10
fackyou00 2020-11-10
Orangesss 2020-11-03
dongCSDN 2020-10-31
rainandtear 2020-10-30
Quietboy 2020-10-30
liuyulong 2020-10-29
fansili 2020-10-29
温攀峰 2020-10-23
jackbon 2020-10-19
kaixinfelix 2020-10-04