python selenium报PATH异常

新手尝试第一次用selenium爬东西,但是第一步就卡住了
我的代码:

from bs4 import BeautifulSoup
from selenium import webdriver
import urllib

driver=webdriver.PhantomJS('C:\phantomjs-2.1.1-windows\bin\phantomjs.exe')
def search(keyword):
    url_keyword=urllib.quote(keyword)
    url="https://www.baidu.com/s?ie=UTF-8&wd="+keyword
    print url
    driver.get(url)
    bsObj=BeautifulSoup(driver.page_source,"html5lib")
    with open("temp.txt","w") as f:
    f.write(bsObj.prettify().encode("utf-8"))

异常问题

clipboard.png
我已经在路径当中加入了phantomjs的路径但是还是报这个问题很奇怪,问问大家有没有遇上这个情况的
下边是我打印的path环境变量的内容:

clipboard.png
我的系统是window10六十四位 ,python版本是2.7.12,selenium是3.0.2

阅读 4k
2 个回答

clipboard.png
你看看我这个就能理解了,跟aristotll是一个意思
另外第一次调试的话推荐用firefox (如果你是selenium 3.x需要下载一个geckodriver 驱动)

不是应该 r'C:\phantomjs-2.1.1-windows\bin\phantomjs.exe'

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进