我已经尝试实现以下内容,传递系统中安装的 phantomJS.exe 的路径。
from splinter import Browser
from selenium import webdriver
driver = webdriver.PhantomJS(executable_path="C:\Users\Lenovo\AppData\Local\Enthought\Canopy\User\Lib\site-packages\phantomJS\phantomJS.exe")
browser = Browser(driver)
browser.visit('www.google.com')
if browser.is_element_present_by_name('search'):
print True
不幸的是,它向我抛出了这个错误:DriverNotFoundError: No driver for <selenium.webdriver.phantomjs.webdriver.WebDriver object at 0x000000000970A8D0>
然而,正如 splinter 中所记录的,我应该能够通过使用browser = Browser('phantomJS')
. 这给了我DriverNotFoundError: No driver for phantomJS'
谁能指出我哪里出错了?