我正在尝试在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'
这就是我正在使用的:
这是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)