当我在 PyCharm 中运行此代码时出现错误
import selenium.webdriver
URL = 'www.ya.ru'
phantom = 'C:\\phantomjs\\bin'
driver = selenium.webdriver.PhantomJS(executable_path=phantom)
driver.get(URL)
File "C:\Users\Дмитрий\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\common\service.py", line 86, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'bin' executable may have wrong permissions.
Windows 10 具有管理员权限。UAC 已禁用。我正在使用管理员权限运行 PyCharm。告诉我出了什么事?
也许您需要将幻影的路径添加到 PATH 我在 Chromedriver 中遇到过类似的情况,它通过添加到 PATH 的路径并像这样运行驱动程序来帮助:
self.driver = webdriver.Chrome() # без пути в скобкахexecutable_path 是可执行文件的完整路径,您只能到该文件夹。添加文件名