• 关于在使用scrapy-redis分布式踩过的那些坑:


    自己的案列:win7上安装ubuntu (win7作为slaver,ubuntu作为master )

    修改配置文件redis.conf

    1)打开配置文件把下面对应的注释掉

    # bind 127.0.0.1

    2)Redis默认不是以守护进程的方式运行,可以通过该配置项修改,设置为no

    daemonize no

    3)保护模式

    protected-mode no

    关键的一步:ubuntu终端命令中重启redis服务的时候如下操作:

    redis-server redis.conf

    在win7上安装RedisDesktopManage查看ubuntur  Redis数据库 (连接方法:完成以上1,2,3即可连接 注意:ubuntu的网络适配器要选择桥接模式。)

    在编写爬虫的时候:

    发现这样写域名的范围会报错(在ubuntu中push url后爬虫没有爬取数据):

    #动态域范围的获取
    def __init__(self, *args, **kwargs):
    # Dynamically define the allowed domains list.
    domain = kwargs.pop('domain', '')
    self.allowed_domains = filter(None, domain.split(','))
    super(MySpider, self).__init__(*args, **kwargs)

    而这样写不会报错:

    allowed_domains = ["xxx.com"]

    在爬虫的settings.py中指明主机地址以及端口号

    如:

    REDIS_HOST = 'x.x.x.x' 主机地址(ubuntu IP地址)
    REDIS_PORT = 6379




     

  • 相关阅读:
    MySQL7:性能优化
    MySQL6:视图
    MySQL5:触发器
    MySQL4:索引
    MySQL3:存储过程和函数
    MySQL1:MySQL函数汇总
    MySQL2:四种MySQL存储引擎
    Spring7:基于注解的Spring MVC(下篇)
    Spring6:基于注解的Spring MVC(上篇)
    Linux查看端口号
  • 原文地址:https://www.cnblogs.com/huwei934/p/7066223.html
Copyright © 2020-2023  润新知