'phantomjs.exe' executable needs to be in PATH. (selenium PhantomJS python)
今天selenium PhantomJS python用了下,发现报错,提示我:'phantomjs.exe' executable needs to be in PATH.
from selenium import webdriver# Open PhantomJS driver = webdriver.PhantomJS(executable_path='C:\phantomjs-2.1.1-windows\bin\phantomjs.exe') 这样运行报错,我百度了下,发现解决方式,在完整路径前面加了一个r 就行了 driver = webdriver.PhantomJS(executable_path=r'C:\phantomjs-2.1.1-windows\bin\phantomjs.exe')
# coding=utf-8
from selenium import webdriver
# Open PhantomJS
driver = webdriver.PhantomJS(executable_path=r'C:\phantomjs-2.1.1-windows\bin\phantomjs.exe')
driver.get("http://www.qq.com")
title = driver.title
driver.save_screenshot('qq.png')
print title #腾讯首页
毕业后这5年里的迷茫,会造成10年后的恐慌,20年后的挣扎,甚至一辈子的平庸!。
人生的道路犹如自己的内裤,没有一条不是自己选的!