Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Python 2.7x中使用Selenium时出现SOCKS错误_Python_Python 2.7_Selenium_Selenium Webdriver - Fatal编程技术网

在Python 2.7x中使用Selenium时出现SOCKS错误

在Python 2.7x中使用Selenium时出现SOCKS错误,python,python-2.7,selenium,selenium-webdriver,Python,Python 2.7,Selenium,Selenium Webdriver,我正在使用Python2.7x,我正在尝试与使用Selenium的网站进行交互。每次我的代码到达代码的这个方面时,我都会得到下面的SOCKS错误。我正在使用Firefox v37和Selenium v2.45.0 Traceback (most recent call last): File "C:\Users\Dell\Desktop\test.py", line 13, in <module> get_password("www.facebook.com") Fi

我正在使用Python2.7x,我正在尝试与使用Selenium的网站进行交互。每次我的代码到达代码的这个方面时,我都会得到下面的
SOCKS
错误。我正在使用Firefox v37和Selenium v2.45.0

Traceback (most recent call last):
  File "C:\Users\Dell\Desktop\test.py", line 13, in <module>
    get_password("www.facebook.com")
  File "C:\Users\Dell\Desktop\test.py", line 6, in get_password
    driver.get(album)
  File "C:\Program Files (x86)\Python2.7.8\lib\site-packages\selenium-2.45.0-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 187, in get
    self.execute(Command.GET, {'url': url})
  File "C:\Program Files (x86)\Python2.7.8\lib\site-packages\selenium-2.45.0-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 175, in execute
    self.error_handler.check_response(response)
  File "C:\Program Files (x86)\Python2.7.8\lib\site-packages\selenium-2.45.0-py2.7.egg\selenium\webdriver\remote\errorhandler.py", line 166, in check_response
    raise exception_class(message, screen, stacktrace)
WebDriverException: Message: f.QueryInterface is not a function
Stacktrace:
    at FirefoxDriver.prototype.get (file:///c:/users/dell/appdata/local/temp/tmpyuwka_/extensions/fxdriver@googlecode.com/components/driver-component.js:10132)
    at DelayedCommand.prototype.executeInternal_/h (file:///c:/users/dell/appdata/local/temp/tmpyuwka_/extensions/fxdriver@googlecode.com/components/command-processor.js:12274)
    at DelayedCommand.prototype.executeInternal_ (file:///c:/users/dell/appdata/local/temp/tmpyuwka_/extensions/fxdriver@googlecode.com/components/command-processor.js:12279)
    at DelayedCommand.prototype.execute/< (file:///c:/users/dell/appdata/local/temp/tmpyuwka_/extensions/fxdriver@googlecode.com/components/command-processor.js:12221)
我怀疑这是一个兼容性问题,将selenium升级到2.45(当前最新版本):

另外,关于代码还有一个简短的补充说明:为什么不在循环之外实例化并退出驱动程序实例?这会对性能产生积极影响:

driver = webdriver.Firefox()
for album in albums:
    for value in content_list:
        ...
driver.quit()

更新:您需要提供URL架构,替换:

get_password("www.facebook.com")
与:


谢谢@alecxe。我运行Firefox v31时遵循了之前关于Selenium错误的建议,但现在我将v37与Selenium 2.45.0一起使用。我现在得到一个新的错误。原文修改谢谢@alexce。现在可以了,所以我知道没有兼容性问题。不过,我的原始代码中仍然有一个错误。我认为该错误与“文件”C:\Program Files(x86)\Python2.7.8\lib\site packages\selenium-2.44.0-py2.7.egg\selenium\webdriver\common\utils.py”有关,第43行,在is_可连接套接字中,连接((“127.0.0.1”,端口))”。上面的代码是独立工作的,但是嵌入在我的主代码中的相同代码不工作。在编写代码期间,我确实通过tor查询了一些URL,所以我确实想知道这是否会导致问题。话虽如此,当我在上面运行时,tor浏览器仍在运行
driver = webdriver.Firefox()
for album in albums:
    for value in content_list:
        ...
driver.quit()
get_password("www.facebook.com")
get_password("https://www.facebook.com")