WebDriverException:消息:无效参数:无法杀死已退出的进程

时间:2019-11-08 21:57:03

标签: python-3.x selenium web-scraping

我是使用Python进行网页抓取的新手。我的目的是检索所关注单词的动词。例如dictionary.com针对单词的不同词性定义,我想输入一个感兴趣的单词,然后点击搜索图标,在结果页面中,我想提取标题“动词”下的信息。

我为此安装了硒

但是我得到了错误: WebDriverException: Message: invalid argument: can't kill an exited process.

我有Firefox版本> 60,Selenium 3.141.0,geckodriver 0.26和Python 2.7(与Python 3.3一起尝试,但得到相同的错误)。

from selenium import webdriver

from selenium.common.exceptions import TimeoutException

from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0

from selenium.webdriver.support import expected_conditions as EC # available since 2.26.0

# Create a new instance of the Firefox driver
driver = webdriver.Firefox()

我的geckodriver位于PATH定义的文件夹中

WebDriverExceptionTraceback (most recent call last)
<ipython-input-7-55833ccbae5a> in <module>()
      8 
      9 # Create a new instance of the Firefox driver
---> 10 driver = webdriver.Firefox(executable_path=r'../webscraping/geckodriver')
     11 
     12 # go to the google home page

../site-packages/selenium/webdriver/firefox/webdriver.pyc in __init__(self, firefox_profile, firefox_binary, timeout, capabilities, proxy, executable_path, options, service_log_path, firefox_options, service_args, desired_capabilities, log_path, keep_alive)
    172                 command_executor=executor,
    173                 desired_capabilities=capabilities,
--> 174                 keep_alive=True)
    175 
    176         # Selenium remote

../site-packages/selenium/webdriver/remote/webdriver.pyc in __init__(self, command_executor, desired_capabilities, browser_profile, proxy, keep_alive, file_detector, options)
    155             warnings.warn("Please use FirefoxOptions to set browser profile",
    156                           DeprecationWarning, stacklevel=2)
--> 157         self.start_session(capabilities, browser_profile)
    158         self._switch_to = SwitchTo(self)
    159         self._mobile = Mobile(self)

../site-packages/selenium/webdriver/remote/webdriver.pyc in start_session(self, capabilities, browser_profile)
    250         parameters = {"capabilities": w3c_caps,
    251                       "desiredCapabilities": capabilities}
--> 252         response = self.execute(Command.NEW_SESSION, parameters)
    253         if 'sessionId' not in response:
    254             response = response['value']

../site-packages/selenium/webdriver/remote/webdriver.pyc in execute(self, driver_command, params)
    319         response = self.command_executor.execute(driver_command, params)
    320         if response:
--> 321             self.error_handler.check_response(response)
    322             response['value'] = self._unwrap_value(
    323                 response.get('value', None))

../site-packages/selenium/webdriver/remote/errorhandler.pyc in check_response(self, response)
    240                 alert_text = value['alert'].get('text')
    241             raise exception_class(message, screen, stacktrace, alert_text)
--> 242         raise exception_class(message, screen, stacktrace)
    243 
    244     def _value_or_default(self, obj, key, default):

WebDriverException: Message: invalid argument: can't kill an exited process

0 个答案:

没有答案