2017-06-30 55 views
0

的Python priting路径我使用它与Python 3.4和硒库运行的脚本,而我得到这个错误用奇怪的字符

PhantomJS with Selenium error: Message: 'phantomjs' executable needs to be in PATH

其中有一个在这里解决

PhantomJS with Selenium error: Message: 'phantomjs' executable needs to be in PATH

但是当我尝试执行解决方案的路径为C:\ DriverPath \ BIN \被错误带来的,当我打印具有它(self.path)的财产,它打印

enter image description here

与点在那里,而不是C:\ DriverPath \ BIN \它不断地引发“PhantomJS硒错误:消息:‘phantomjs’可执行文件需要在PATH”。任何想法,难道是

+2

我认为,这是窗口渲染'\ b'的方式。在python中设置路径时,可以使用反斜线(即“C:\\ DriverPath \\ Bin \\”)或使用原始字符串(即“r”C:\ DriverPath \ Bin \“')。 –

回答

1

硒3.4.3 & PhantomJS工作2.1.1使用Python 3.6.1以下几行代码将初始化PhantomJS驱动PERFECTO:

driver = webdriver.PhantomJS(executable_path="C:\\Utility\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe") 
driver.get("https://www.booking.com/") 

让我知道如果这个答案你的问题。