centos运行selenium

一、安装chrome及chromedriver

https://www.cnblogs.com/somenothing/p/14356004.html

二、安装selenium库

pip install selenium

pip3 install selenium

三、配置环境变量

直接把chromedriver移动到 /usr/bin

sudo mv chromedriver /usr/bin

四、python代码示例

chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--no-sandbox')
browser=webdriver.Chrome(executable_path="/usr/bin/chromedriver", chrome_options=chrome_options)

 

posted @ 2021-02-01 12:47  五夜  阅读(468)  评论(0)    收藏  举报