相关疑难解决方法(0)

TypeError: WebDriver.__init__() 在 Selenium Python 中使用 firefox_options 作为参数时出现意外的关键字参数 'firefox_options' 错误

我正在尝试创建一个从网站下载文件的脚本,为此我想更改下载文件路径。当我尝试使用 Firefox 选项执行此操作时,出现以下错误:

TypeError: WebDriver.__init__() got an unexpected keyword argument 'firefox_options'
Run Code Online (Sandbox Code Playgroud)

代码:

from selenium import webdriver
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.common.keys import Keys
import time

options = Options()

options.add_argument("download.default_directory=C:\\Music")
browser = webdriver.Firefox(firefox_options=options, executable_path=r'C:\\selenium\\geckodriver.exe')
browser.get('https://duckduckgo.com/')
Run Code Online (Sandbox Code Playgroud)

python firefox selenium selenium-webdriver geckodriver

15
推荐指数
1
解决办法
3万
查看次数

WebDriverException:消息:服务chromedriver意外退出.状态代码是:127

我想在我的服务器上使用selenium构建我的爬虫.

因此我在我的Ubuntu17.10服务器上安装/下载了所需的依赖项 - 例如chromedriver,chromium-browser等

但是,当我运行以下代码时:

driver = webdriver.Chrome()
Run Code Online (Sandbox Code Playgroud)

它返回以下错误:

---------------------------------------------------------------------------
WebDriverException                        Traceback (most recent call last)
<ipython-input-14-2cdab8938403> in <module>()
----> 1 driver = webdriver.Chrome()

/home/zachary/.local/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py in __init__(self, executable_path, port, options, service_args, desired_capabilities, service_log_path, chrome_options)
     66             service_args=service_args,
     67             log_path=service_log_path)
---> 68         self.service.start()
     69 
     70         try:

/home/zachary/.local/lib/python3.6/site-packages/selenium/webdriver/common/service.py in start(self)
     96         count = 0
     97         while True:
---> 98             self.assert_process_still_running()
     99             if self.is_connectable():
    100                 break

/home/zachary/.local/lib/python3.6/site-packages/selenium/webdriver/common/service.py in assert_process_still_running(self)
    109             raise WebDriverException(
    110                 'Service %s unexpectedly exited. Status code was: %s'
--> 111                 % …
Run Code Online (Sandbox Code Playgroud)

python selenium google-chrome selenium-chromedriver selenium-webdriver

12
推荐指数
5
解决办法
3万
查看次数