Ubuntu 使用scrapy-splash

配置docker

1.更新apt索引:python

$ sudo apt-get updatelinux

2.安裝包容許apt經過HTTPS使用倉庫:docker

 sudo dpkg --configure -a ubuntu

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

3.添加Docker官方GPG key:瀏覽器

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

4.設置Docker穩定版倉庫:
curl

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

5.更新apt源索引 網站

 sudo apt-get update

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的圖像識庫目前很難識破這些網站的驗證碼,恐怕要加入更爲先進的圖像識別工具

相關文章
相關標籤/搜索