英文:
Selenium Error: "unrecognized proxy type: MANUAL"
问题
我正在尝试学习如何使用代理服务器运行Selenium WebDriver,但直接按照提供的代码文档进行操作:
from selenium import webdriver
PROXY = "<HOST:PORT>"
webdriver.DesiredCapabilities.FIREFOX['proxy'] = {
"httpProxy": PROXY,
"ftpProxy": PROXY,
"sslProxy": PROXY,
"proxyType": "MANUAL",
}
with webdriver.Firefox() as driver:
driver.get("https://selenium.dev")
会产生以下错误:
selenium.common.exceptions.InvalidArgumentException: Message: Invalid proxyType value: MANUAL
文档是否已过时,还是我还有其他方面需要考虑?
有关相关文档,请查看此链接。
英文:
I'm trying to learn how to run a selenium webdriver with a proxy server, but directly following the documentation with the provided code:
from selenium import webdriver
PROXY = "<HOST:PORT>"
webdriver.DesiredCapabilities.FIREFOX['proxy'] = {
"httpProxy": PROXY,
"ftpProxy": PROXY,
"sslProxy": PROXY,
"proxyType": "MANUAL",
}
with webdriver.Firefox() as driver:
driver.get("https://selenium.dev")
yields the following error:
> selenium.common.exceptions.InvalidArgumentException: Message: Invalid proxyType value: MANUAL
Is the documentation outdated or is there something else I'm not taking into account here?
The documentation in question can be found here
答案1
得分: 0
将值从 MANUAL
更改为 manual
即可消除下面的异常:
Message: 无效的代理类型值: MANUAL
如果出现以下异常,请删除此行 "ftpProxy": PROXY,
:
Message: SessionNotCreatedError: InvalidArgumentError: 自从 Firefox 90 起 'ftpProxy' 不再受支持
参考下面的代码:
from selenium import webdriver
PROXY = "<HOST:PORT>"
webdriver.DesiredCapabilities.FIREFOX['proxy'] = {
"httpProxy": PROXY,
"sslProxy": PROXY,
"proxyType": "manual",
}
with webdriver.Firefox() as driver:
driver.get("https://selenium.dev")
英文:
By changing the value from MANUAL
to manual
you can get rid of below exception
Message: Invalid proxyType value: MANUAL
And if you get below exception then remove this line "ftpProxy": PROXY,
.
Message: SessionNotCreatedError: InvalidArgumentError: Since Firefox 90 'ftpProxy' is no longer supported
Refer code below:
from selenium import webdriver
PROXY = "<HOST:PORT>"
webdriver.DesiredCapabilities.FIREFOX['proxy'] = {
"httpProxy": PROXY,
"sslProxy": PROXY,
"proxyType": "manual",
}
with webdriver.Firefox() as driver:
driver.get("https://selenium.dev")
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论