selenium.common.exceptions.WebDriverException: Message: 'phantomjs' executable needs to be in PATH
在使用phantomjs的过程中发生了如题目一样的报错信息,执行的为以下代码:
from selenium import webdriver
browser = webdriver.PhantomJS()
browser.get('https://www.baidu.com')
print(browser.current_url)
解决:
from selenium import webdriver
browser = webdriver.PhantomJS(executable_path=r'E:\phantomjs-2.1.1-windows\bin\phantomjs.exe')
browser.get('https://www.baidu.com')
print(browser.current_url)
参考: https://blog.****.net/JohinieLi/article/details/76622776