您的位置:首页 > 编程语言 > Python开发

'phantomjs.exe' executable needs to be in PATH. (selenium PhantomJS python)

2018-01-29 15:31 543 查看
今天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   #腾讯首页


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐