Ubuntu 使用scrapy-splash

配置docker

1.更新apt索引:

$ sudo apt-get update

2.安装包允许apt通过HTTPS使用仓库:

 sudo dpkg --configure -a

 sudo apt-get install apt-transport-https ca-certificates curl software-properties-common

3.添加Docker官方GPG key:

 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

4.设置Docker稳定版仓库:

 sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

5.更新apt源索引 

 sudo apt-get update

扫描二维码关注公众号,回复: 8205238 查看本文章

6.安装最新版本Docker CE(社区版) 

 sudo apt-get install docker-ce

7.检查版本:
 docker --version

8.检查CE是否正确安装 
 sudo docker run hello-world

关于splash的配置

1.开启docker:
   sudo service docker start

   关闭docker:

   sudo service docker stop

2.重启docker:

 sudo systemctl restart docker.service

3.安装splash所依赖的数据:

    sudo docker pull scrapinghub/splash

    可以先使用下面的命令对splash镜像拉取进行加速(代理完成后系统会提示重启docker):

    sudo curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://xxxxxx.m.daocloud.io

4.打开splash镜像

    sudo docker run -p 8050:8050 scrapinghub/splash

5.下载成功后在浏览器输入:http://localhost:8050,开启对splash的监听

注意,这种方法并不是一劳永逸的,依旧会被大型网站设置反爬策略。最要命的就是网站设置验证码,而python的图像识库目前很难识破这些网站的验证码,恐怕要加入更为先进的图像识别工具

 

猜你喜欢

转载自www.cnblogs.com/PKU-CD/p/12034905.html