硒/ PhantomJS引发错误 [英] Selenium/PhantomJS raises error
本文介绍了硒/ PhantomJS引发错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图运行的 PhantomJS 驱动器的Python 但是我得到的错误。我读过,我应该通过整个路径作为参数,但它并没有帮助。
I'm trying to run PhantomJS driver in Python but I'm getting error. I've read that I should pass the whole path as an argument but it didn't help.
下面是code:
from selenium import webdriver
# driver = webdriver.Chrome('D:\Python_projects\chromedriver_win32/chromedriver.exe') # this works
driver = webdriver.PhantomJS(executable_path='D:\Python\phantomjs-2.0.0-windows\bin\phantomjs.exe')
ERROR:
Traceback (most recent call last):
File "path to script", line 8, in <module>
driver = webdriver.PhantomJS(executable_path='D:\Python\phantomjs-2.0.0-windows\bin\phantomjs.exe')
File "C:\Python27\lib\site-packages\selenium\webdriver\phantomjs\webdriver.py", line 50, in __init__
self.service.start()
File "C:\Python27\lib\site-packages\selenium\webdriver\phantomjs\service.py", line 75, in start
raise WebDriverException("Unable to start phantomjs with ghostdriver.", e)
selenium.common.exceptions.WebDriverException: Message: Unable to start phantomjs with ghostdriver.
Screenshot: available via screen
你知道我在做什么错了?
Do you know what am I doing wrong?
推荐答案
请在原始字符串的路径,加上R:&NBSP;
Make the path in raw string, add 'r':
driver = webdriver.PhantomJS(executable_path=r'D:\Python\phantomjs-2.0.0-windows\bin\phantomjs.exe')
这篇关于硒/ PhantomJS引发错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文