Scrapy+splash报错 Connection was refused by other side

报错信息如下:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/scrapy/core/downloader/middleware.py", line 43, in process_request
    defer.returnValue((yield download_func(request=request,spider=spider)))
twisted.internet.error.ConnectionRefusedError: Connection was refused by other side: 111: Connection refused.


先说一下环境:Dokcer+Postgresql9.6+Scrapy 1.6.0+splash3.3.1

按照以往的步骤:

首先启动splash   docker run -d(后台运行)  --name   你的容器名(可以没有)  scrapinghub/splash   /bin/bash

然后在容器内 scrapy check   -----完美,没有任何报错。但是在开启爬虫后出现 了如上报错信息。

最后在https://stackoverflow.com/questions/44835828/scrapy-splash-connection-refused  这个老哥收到启发

原来是启动splash 没有指定端口映射 

启动splash命令加上端口映射:

   docker run -d(后台运行)  --name   你的容器名(可以没有) -p 8050:8050 scrapinghub/splash   /bin/bash

最后在浏览器输入localhost:8050看是否能看到如下界面:

最后爬虫不再报错,完美解决

posted @ 2019-12-20 10:05  二锅头不上头  阅读(577)  评论(0编辑  收藏  举报