docker 安装
Mac 安装
brew cask install docker
ubuntu 安装
- 安装
wget -qO- https://get.docker.com/ | sh
- 启动
sudo service docker start
- 修改仓库源
- 配置 /etc/docker/daemon.js
{
“registry-mirrors”: [“https://registry.docker-cn.com“]
}
- 重启
# 机器重启
sudo reboot
splash 安装
sudo docker pull scrapinghub/splash
运行 splash
sudo docker run -p 8050:8050 scrapinghub/splash
scrapy 使用 splash
- 配置之前先得安装
pip install scrapy-splash
- 配置settings.py
# 添加 splash 服务器地址
SPLASH_URL = 'http://127.0.0.1:8050'
# 配置下载中间件
DOWNLOADER_MIDDLEWARES = {
# 'github.middlewares.SeleniumMiddleware': 543,
'scrapy_splash.SplashCookiesMiddleware': 723,
'scrapy_splash.SplashMiddleware': 725,
'scrapy.downloadermiddlewares.httpcompression.HttpCompressionMiddleware': 810,
}
- 使用 splash 提供的请求对象
网友评论