1、yum seach firefox
选择64位狐火浏览器安装
whereis firefox
查看安装目录
2、下载geckodriver
https://npm.taobao.org/mirrors/geckodriver/v0.29.0/geckodriver-v0.29.0-linux64.tar.gz
解压放到firefox安装目录
复制一份到/usr/bin ,省去指定路径
3、把firefox安装目录加入环境变量PATH
export PATH="$PATH:/usr/lib64/firefox"
4、测试使用
from selenium import webdriver
options = webdriver.FirefoxOptions()
options.add_argument('-headless')
driver = webdriver.Firefox(firefox_options=options)
driver.get('http://www.baidu.com')
title = driver.title
print('title:'+title)
now_url = driver.current_url
print('URL:' + now_url)
driver.close()