Service phantomjs unexpectedly exited. Status code was: 1
python进行爬虫处理时,运用 selenium 的 webdriver.PhantomJS 时一直报错,说是意外退出,状态码为1,
# 测试代码
# 自动按照环境变量查找相应的浏览器
driver = webdriver.PhantomJS()
Service phantomjs unexpectedly exited. Status code was: 1
后来参考相关文章 在括号中添加相关路径 即可运行,究其原因drive默认为自动寻找,但是由于一些原因又找不大所以就报错了。
driver = webdriver.PhantomJS("F:\Desktop\phantomjs-2.1.1-windows\\bin\phantomjs.exe")
PhantomJS下载网址:https://phantomjs.org/download.html
同样的类似错误 chromedrive 显示 Status code was: 1 的处理方式也是一样。
# 错误信息
selenium.common.exceptions.WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 1
# 可能需要手动添加路径
driver = webdriver.Chrome("F:\Desktop\chromedriver_win32\chromedriver.exe")
chromedriver下载网址:http://chromedriver.storage.googleapis.com/index.html
参考文章:【1】Python脚本报错:selenium.common.exceptions.WebDriverException: Message: Service chromedriver.exe unexpect
【2】ChromeDriver的下载
还没有评论,来说两句吧...