selenium 集群搭建

本文以 centos 为例,介绍下如何搭建 selenium 集群。

##selenium 安装

chrome 安装

chrome driver 安装

http://chromedriver.storage.googleapis.com/index.html 下载之后解压到到 /usr/bin/ 目录即可。macos可以使用 brew安装:

1
brew cask install chromedriver

设置 headless

所谓 headless就是不用 GUI, 设置方式如下 :

1
2
3
4
5
6
7
8
9
10
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.add_argument('--headless')
options.add_argument('--disable-gpu') # Last I checked this was necessary.
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--no-sandbox')

driver = webdriver.Chrome(options=options)