python无法创建selenium.webdriver.PhantomJS
苹果的操作系统,python3.6
代码如下:
from selenium import webdriver
import time
driver = webdriver.PhantomJS(executable_path='/Users/apple/phantomjs/bin/phantomjs')
driver.get('http://pythonscraping.com/pages/javascript/ajaxDemo.html')
time.sleep(3)
print(driver.find_element_by_id('content').text)
driver.close()
错误信息:
WebDriverException Traceback (most recent call last)
<ipython-input-3-ffd0972f34d5> in <module>()
----> 1 driver = webdriver.PhantomJS(executable_path='/Users/apple/phantomjs/bin/phantomjs')
2 driver.get('http://pythonscraping.com/pages/javascript/ajaxDemo.html')
3 time.sleep(3)
4 print(driver.find_element_by_id('content').text)
5 driver.close()
/Users/apple/anaconda/lib/python3.6/site-packages/selenium/webdriver/phantomjs/webdriver.py in __init__(self, executable_path, port, desired_capabilities, service_args, service_log_path)
50 service_args=service_args,
51 log_path=service_log_path)
---> 52 self.service.start()
53
54 try:
/Users/apple/anaconda/lib/python3.6/site-packages/selenium/webdriver/common/service.py in start(self)
100 time.sleep(1)
101 if count == 30:
--> 102 raise WebDriverException("Can not connect to the Service %s" % self.path)
103
104 def assert_process_still_running(self):
WebDriverException: Message: Can not connect to the Service /Users/apple/phantomjs/bin/phantomjs
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
感觉是phantomjs的路径问题,找了篇这个,你看看
https://codedump.io/share/LjA...