Selenium和PhantomJS错误:“无法连接到GhostDriver”

2024-05-23 13:58:31 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在运行Selenium和PhantomJS,将搜索项输入到网站中,并检索每个搜索项的点击数。我必须做130000多次,所以代码已经很好地运行了一天,直到程序突然崩溃并出现以下错误:

Traceback (most recent call last):
  File "CBBPlyNwsScrape.py", line 82, in <module>
     browser = webdriver.PhantomJS()
  File "/Library/Python/2.7/site-packages/selenium/webdriver/phantomjs/webdriver.py", line 50, in __init__
     self.service.start()
  File "/Library/Python/2.7/site-packages/selenium/webdriver/phantomjs/service.py", line 69, in start
     raise WebDriverException("Can not connect to GhostDriver")
selenium.common.exceptions.WebDriverException: Message: 'Can not connect to GhostDriver' 

我在MacOSX和Python2.7.3上运行这个。我已经安装了最新版本的Selenium和PhantomJS。有谁能告诉我发生了什么事,为什么幽灵司机工作这么长时间都很好,突然停了下来?

ghostdriver.log文件中,它只包含以下内容:

PhantomJS is launching GhostDriver...
[ERROR - 2013-12-01T05:14:34.491Z] GhostDriver - Main - Could not start Ghost Driver => {
  "message": "Could not start Ghost Driver",
  "line": 82,
  "sourceId": 4445044288,
  "sourceURL": ":/ghostdriver/main.js",
  "stack": "Error: Could not start Ghost Driver\n    at :/ghostdriver/main.js:82",
  "stackArray": [
     {
        "sourceURL": ":/ghostdriver/main.js",
        "line": 82
     }
  ]
}

谢谢


Tags: inpymaindriverseleniumlinenotphantomjs