我的代码,本来昨天还可以工作的,突然停止工作了。我一直在运行jupyter notebook中的代码,从网页中自动收集重复数据。内容如下(出于隐私原因,URL改为Google):
# use selenium to start Chrome session to open a certain page
dr = webdriver.Chrome()
dr.get("http://www.google.com")
我得到的错误信息:
---------------------------------------------------------------------------
WebDriverException Traceback (most recent call last)
<ipython-input-25-84be89301b0d> in <module>()
1 # use selenium to start Chrome session to open google.
----> 2 dr = webdriver.Chrome()
3 dr.get("http://www.google.com")
/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/chrome/webdriver.py in __init__(self, executable_path, port, chrome_options, service_args, desired_capabilities, service_log_path)
65 command_executor=ChromeRemoteConnection(
66 remote_server_addr=self.service.service_url),
---> 67 desired_capabilities=desired_capabilities)
68 except:
69 self.quit()
/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py in __init__(self, command_executor, desired_capabilities, browser_profile, proxy, keep_alive)
85 self.error_handler = ErrorHandler()
86 self.start_client()
---> 87 self.start_session(desired_capabilities, browser_profile)
88 self._switch_to = SwitchTo(self)
89 self._mobile = Mobile(self)
/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py in start_session(self, desired_capabilities, browser_profile)
139 desired_capabilities['firefox_profile'] = browser_profile.encoded
140 response = self.execute(Command.NEW_SESSION, {
--> 141 'desiredCapabilities': desired_capabilities,
142 })
143 self.session_id = response['sessionId']
/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py in execute(self, driver_command, params)
199 response = self.command_executor.execute(driver_command, params)
200 if response:
--> 201 self.error_handler.check_response(response)
202 response['value'] = self._unwrap_value(
203 response.get('value', None))
/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/errorhandler.py in check_response(self, response)
179 elif exception_class == UnexpectedAlertPresentException and 'alert' in value:
180 raise exception_class(message, screen, stacktrace, value['alert'].get('text'))
--> 181 raise exception_class(message, screen, stacktrace)
182
183 def _value_or_default(self, obj, key, default):
WebDriverException: Message: session not created exception
from unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"7600.1","isDefault":true},"id":1,"name":"","origin":"://"}
(Session info: chrome=54.0.2840.71)
(Driver info: chromedriver=2.20.353124 (035346203162d32c80f1dce587c8154a1efa0c3b),platform=Mac OS X 10.11.6 x86_64)
我真的不知道如何解决这个问题,为什么我突然收到这个消息。
从下面的链接重新下载新的chrome驱动程序,并使用相同的
http://chromedriver.storage.googleapis.com/index.html?path=2.24/