python - 如何在带有 Firefox 的 CentOS 6.10 中使用 Python 运行 selenium webdriver
问题描述
我正在尝试在 CentOS 服务器中运行 Python 脚本。但是,我一直无法安装 Google Chrome(我已经读过它不再受 CentOS 支持),所以我决定尝试使用 Firefox。但是,尝试使用 Firefox 运行它时出现以下错误。
Traceback (most recent call last):
File "/home/uscomplianceserv/public_html/scrapdata/FMCSAScraper.py", line 73, in <module>
init_selenium()
File "/home/uscomplianceserv/public_html/scrapdata/FMCSAScraper.py", line 40, in init_selenium
webdriver.Firefox(firefox_options = options, executable_path='/home/uscomplianceserv/public_html/scrapdata/geckodriver')
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 133, in __init__
if options.binary is not None:
AttributeError: 'Options' object has no attribute 'binary'
这就是我正在使用的:
- Centos 6.10
- 蟒蛇 2.7
- 硒 3.14.0
- 火狐 45
- 壁虎驱动 v0.21.0
这是 selenium webdriver 初始化函数:
def init_selenium():
global driver, page
options = Options()
options.add_argument("-headless")
driver = webdriver.Firefox(firefox_options = options, executable_path='/home/uscomplianceserv/public_html/scrapdata/geckodriver')
driver.get(url)
解决方案
推荐阅读
- javascript - Cordova:从 SD 卡中读取目录和文件
- c - 在这个 pthreading C 程序中避免死锁的一些提示
- ios - 如何修复 UIButton 的 sizeToFit/sizeThatFit 的宽度?
- google-api - Google Places API 不返回结果
- termux - 在 termux 中创建 metasploit 有效负载
- c++ - 从交换链获取多个屏幕缓冲区
- assembly - 程序集:使用“.equ”的无效操作数错误减去 2 个字符文字
- c# - 如何使用反射调用具有 0 个参数的非公共方法?
- c - 是否有解决此错误的方法:预期标识符或数字常量前的“(”?
- ruby - 冒泡排序算法中整数与 nil 的比较失败