网上的某测试代码:
from selenium import webdriver
driver = webdriver.PhantomJS(executable_path="C:\Python27\Scripts\phantomjs-2.1.1-windows\bin\phantomjs.exe")
driver.get("http://www.baidu.com")
data = driver.title
print data
配置环境变量path
C:\Python27\Scripts\phantomjs-2.1.1-windows\bin
无效(此处发现有人的错误是路径一直写到了xxx.exe)
检查源程序
发现自己原来把Scripts打成了Script
路径请复制不要手打!
仍有错
最终
Windows环境下完整路径前加r!!!
即
executable_path=r"C:\Python27\Scripts\phantomjs-2.1.1-windows\bin\phantomjs.exe"
解决