Python 为什么不';你不能加载firefox配置文件吗?

Python 为什么不';你不能加载firefox配置文件吗?,python,firefox,selenium-webdriver,Python,Firefox,Selenium Webdriver,以下代码: from selenium import webdriver from selenium.common.exceptions import TimeoutException from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0 from selenium.webdriver.support import expected_conditions as EC # available

以下代码:

from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0
from selenium.webdriver.support import expected_conditions as EC # available since 2.26.0
import os.path
import os
FIREFOX_PATH = os.path.join("C:", 
                            "FirefoxPortable", "FirefoxPortable.exe")
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
binary = FirefoxBinary(FIREFOX_PATH)
driver = webdriver.Firefox(firefox_binary=binary)

# go to the google home page
driver.get("http://www.google.com")
失败,投诉无法加载配置文件:

$ python test_selenium.py
Traceback (most recent call last):
  File "test_selenium.py", line 17, in <module>
    driver = webdriver.Firefox(firefox_profile=profile,firefox_binary=binary)
  File "/usr/lib/python2.7/site-packages/selenium-2.45.0-py2.7.egg/selenium/webdriver/firefox/webdriver.py", line 59, in __init__
    self.binary, timeout),
  File "/usr/lib/python2.7/site-packages/selenium-2.45.0-py2.7.egg/selenium/webdriver/firefox/extension_connection.py", line 47, in __init__
    self.binary.launch_browser(self.profile)
  File "/usr/lib/python2.7/site-packages/selenium-2.45.0-py2.7.egg/selenium/webdriver/firefox/firefox_binary.py", line 66, in launch_browser
    self._wait_until_connectable()
  File "/usr/lib/python2.7/site-packages/selenium-2.45.0-py2.7.egg/selenium/webdriver/firefox/firefox_binary.py", line 105, in _wait_until_connectable
    raise WebDriverException("Can't load the profile. Profile "
selenium.common.exceptions.WebDriverException: Message: Can't load the profile. Profile Dir: %s If you specified a log_file in the FirefoxBinary constructor, check it for details.
$python test\u selenium.py
回溯(最近一次呼叫最后一次):
文件“test_selenium.py”,第17行,在
driver=webdriver.Firefox(Firefox\u profile=profile,Firefox\u binary=binary)
文件“/usr/lib/python2.7/site packages/selenium-2.45.0-py2.7.egg/selenium/webdriver/firefox/webdriver.py”,第59行,在__
self.binary,超时),
文件“/usr/lib/python2.7/site packages/selenium-2.45.0-py2.7.egg/selenium/webdriver/firefox/extension_connection.py”,第47行,在u init中__
self.binary.launch_浏览器(self.profile)
文件“/usr/lib/python2.7/site packages/selenium-2.45.0-py2.7.egg/selenium/webdriver/firefox/firefox\u binary.py”,第66行,在launch\u浏览器中
self.\u等待\u直到\u可连接()
文件“/usr/lib/python2.7/site packages/selenium-2.45.0-py2.7.egg/selenium/webdriver/firefox/firefox\u binary.py”,第105行,在“等待”直到“可连接”
引发WebDriverException(“无法加载配置文件。配置文件”
selenium.common.exceptions.WebDriverException:消息:无法加载配置文件。配置文件目录:%s如果您在FirefoxBinary构造函数中指定了日志文件,请检查它以了解详细信息。
你知道发生了什么事吗

我承认我一点也不在乎个人资料(而且对个人资料只有模糊的感觉)——我只想加载一个基本的浏览器,这样我就可以自动进行一些网页抓取

非常感谢! /YGA

根据问题,指定以下路径。这将搜索
D://
中的
FirefoxPortable
文件夹

FIREFOX_PATH = os.path.join("D:/", "FirefoxPortable", "FirefoxPortable.exe")
另外,下面的代码工作正常。我删除了
import os
行,因为它是多余的

from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0
from selenium.webdriver.support import expected_conditions as EC # available since 2.26.0
import os.path

from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

FIREFOX_PATH = os.path.join("D:/", "FirefoxPortable", "FirefoxPortable.exe")
binary = FirefoxBinary(FIREFOX_PATH)
driver = webdriver.Firefox(firefox_binary=binary)

# go to the google home page
driver.get("http://www.google.com")
driver.quit()

您能指定您的操作系统和firefox版本吗?