我是python新手,当我想运行以下简单代码时,我遇到了一个错误:
from selenium import webdriver
browser = webdriver.Firefox()
browser.get("http://www.whatsmyip.org")
错误:
Traceback (most recent call last):
File "C:\Users\Saeed\Desktop\insta bot\instagram.py", line 3, in <module>
browser = webdriver.Firefox()
File "C:\Users\Saeed\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 177, in __init__
executor = FirefoxRemoteConnection(
File "C:\Users\Saeed\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\firefox\remote_connection.py", line 27, in __init__
RemoteConnection.__init__(self, remote_server_addr, keep_alive, ignore_proxy=ignore_proxy)
File "C:\Users\Saeed\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 155, in __init__
self._conn = self._get_connection_manager()
File "C:\Users\Saeed\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 143, in _get_connection_manager
urllib3.ProxyManager(self._proxy_url, **pool_manager_init_args)
File "C:\Users\Saeed\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\poolmanager.py", line 480, in __init__
raise ProxySchemeUnknown(proxy.scheme)
urllib3.exceptions.ProxySchemeUnknown: Proxy URL had no scheme, should start with http:// or https://
提前感谢您的指导
当客户端代码(测试)尝试向WebDriver服务发送命令时,会出现此错误。由于是REST(通过http),因此Selenium采用在相应协议的环境变量中定义的代理:
看起来分配给其中一个(或两个)变量的值不是正确的URL
解决办法是:
FirefoxOptions
中切换ignore_local_proxy_environment_variables
相关问题 更多 >
编程相关推荐