Service phantomjs unexpectedly exited. Status code was: 1

冷不防 2021-11-19 14:22 293阅读 0赞

  python进行爬虫处理时,运用 seleniumwebdriver.PhantomJS 时一直报错,说是意外退出,状态码为1,

  1. # 测试代码
  2. # 自动按照环境变量查找相应的浏览器
  3. driver = webdriver.PhantomJS()
  4. Service phantomjs unexpectedly exited. Status code was: 1

  后来参考相关文章 在括号中添加相关路径 即可运行,究其原因drive默认为自动寻找,但是由于一些原因又找不大所以就报错了。

  1. driver = webdriver.PhantomJS("F:\Desktop\phantomjs-2.1.1-windows\\bin\phantomjs.exe")

  PhantomJS下载网址:https://phantomjs.org/download.html


  同样的类似错误 chromedrive 显示 Status code was: 1 的处理方式也是一样。

  1. # 错误信息
  2. selenium.common.exceptions.WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 1
  3. # 可能需要手动添加路径
  4. 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的下载

发表评论

表情:
评论列表 (有 0 条评论,293人围观)

还没有评论,来说两句吧...

相关阅读