__init__() got multiple values for argument 'options
时间: 2024-01-01 13:22:53 浏览: 60
根据你提供的信息,我无法确定问题的具体原因。但是,通常情况下,当出现“__init__() got multiple values for argument”错误时,这意味着您在函数调用中多次传递了同一个参数。您可以检查您的代码,确保您没有多次传递相同的参数。如果您仍然无法解决问题,请提供更多的上下文和代码,以便我更好地帮助您解决问题。
相关问题
WebDriver.__init__() got multiple values for argument 'options'
The error message "WebDriver.__init__() got multiple values for argument 'options'" indicates that you are passing the 'options' argument multiple times when initializing the WebDriver.
To fix this issue, you need to ensure that you are passing the 'options' argument only once. Here's an example of the correct usage:
```python
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
# Create an instance of ChromeOptions
chrome_options = Options()
# Add any desired options to the ChromeOptions object
chrome_options.add_argument("--headless") # Example: Running Chrome in headless mode
# Initialize the WebDriver with the options
driver = webdriver.Chrome(options=chrome_options)
```
In the above code, we create an instance of `ChromeOptions` and add any desired options to it. Then, when initializing the `webdriver.Chrome` object, we pass the `chrome_options` object to the `options` argument.
Make sure you are not passing the `options` argument twice or assigning it a value somewhere else in your code, as that can lead to the "got multiple values for argument 'options'" error.
I hope this helps! Let me know if you have any further questions.
__init__() got multiple values for argument 'options'
这个错误是因为在调用 `__init__()` 方法时,传递了多个值给了参数 `options`。这可能是因为你同时使用了 `chrome_options` 和 `options` 这两个参数,造成了冲突。
请检查你的代码,确保只传递一个值给参数 `options`。如果你需要使用 `chrome_options`,则应该将其替换为 `options`。修改后的代码如下所示:
```python
if engine != "Baidu":
browser = str.lower(browser)
if "chrome" in browser:
chrome_path = shutil.which("chromedriver")
chrome_path = "./bin/chromedriver" if chrome_path is None else chrome_path
options = webdriver.ChromeOptions()
if "headless" in browser:
options.add_argument("headless")
if proxy is not None and proxy_type is not None:
options.add_argument("--proxy-server={}://{}".format(proxy_type, proxy))
driver = webdriver.Chrome(chrome_path, options=options)
else:
phantomjs_path = shutil.which("phantomjs")
phantomjs_path = "./bin/phantomjs" if phantomjs_path is None else phantomjs_path
phantomjs_args = []
if proxy is not None and proxy_type is not None:
phantomjs_args += [
"--proxy=" + proxy,
"--proxy-type=" + proxy_type,
]
driver = webdriver.PhantomJS(executable_path=phantomjs_path,
service_args=phantomjs_args, desired_capabilities=dcap)
```
确保你只传递一个值给参数 `options`,并且没有重复的参数传递。如果问题仍然存在,请提供更多的上下文和代码,以便我能够更好地帮助你解决问题。