http://stackoverflow.com/questions/39998330/selenium-common-exceptions-webdriverexception-message-se

本文尝试使用Selenium WebDriver通过指定的浏览器驱动程序访问雅虎财经网站的增益页面,但遇到了浏览器驱动程序启动失败的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 decode: utf-8
import os
from selenium import webdriver
import time

firefox_driver = r"C:\Program Files (x86)\Mozilla Firefox\firefox.exe"
driver = webdriver.Firefox(executable_path = firefox_driver)
driver.get("http://finance.yahoo.com/gainers?e=us")
driver.close()


--------------------------------------------------------------------
WebDriverException                 Traceback (most recent call last)
<ipython-input-3-06211bd8fae0> in <module>()
      5 
      6 firefox_driver = r"C:\Program Files (x86)\Mozilla Firefox\firefox.exe"
----> 7 driver = webdriver.Firefox(executable_path = firefox_driver)
      8 driver.get("http://finance.yahoo.com/gainers?e=us")
      9 driver.find_element_by_tag_name("div")

C:\Program Files\Anaconda3\lib\site-packages\selenium\webdriver\firefox\webdriver.py in __init__(self, firefox_profile, firefox_binary, timeout, capabilities, proxy, executable_path, firefox_options, log_path)
    138         if capabilities.get("marionette"):
    139             self.service = Service(executable_path, log_path=log_path)
--> 140             self.service.start()
    141 
    142             capabilities.update(firefox_options.to_capabilities())

C:\Program Files\Anaconda3\lib\site-packages\selenium\webdriver\common\service.py in start(self)
     94         count = 0
     95         while True:
---> 96             self.assert_process_still_running()
     97             if self.is_connectable():
     98                 break

C:\Program Files\Anaconda3\lib\site-packages\selenium\webdriver\common\service.py in assert_process_still_running(self)
    107             raise WebDriverException(
    108                 'Service %s unexpectedly exited. Status code was: %s'
--> 109                 % (self.path, return_code)
    110             )
    111 

WebDriverException: Message: Service C:\Program Files (x86)\Mozilla Firefox\firefox.exe unexpectedly exited. Status code was: 1

import os
from selenium import webdriver
chromedriver = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
driver =  webdriver.Chrome(chromedriver)
driver.get("http://finance.yahoo.com/gainers?e=us")
driver.close()

--------------------------------------------------------------------
WebDriverException                 Traceback (most recent call last)
<ipython-input-1-6788a60d5105> in <module>()
      2 from selenium import webdriver
      3 chromedriver = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
----> 4 driver =  webdriver.Chrome(chromedriver)
      5 driver.get("http://finance.yahoo.com/gainers?e=us")
      6 driver.close()

C:\Program Files\Anaconda3\lib\site-packages\selenium\webdriver\chrome\webdriver.py in __init__(self, executable_path, port, chrome_options, service_args, desired_capabilities, service_log_path)
     60             service_args=service_args,
     61             log_path=service_log_path)
---> 62         self.service.start()
     63 
     64         try:

C:\Program Files\Anaconda3\lib\site-packages\selenium\webdriver\common\service.py in start(self)
     94         count = 0
     95         while True:
---> 96             self.assert_process_still_running()
     97             if self.is_connectable():
     98                 break

C:\Program Files\Anaconda3\lib\site-packages\selenium\webdriver\common\service.py in assert_process_still_running(self)
    107             raise WebDriverException(
    108                 'Service %s unexpectedly exited. Status code was: %s'
--> 109                 % (self.path, return_code)
    110             )
    111 

WebDriverException: Message: Service C:\Program Files (x86)\Google\Chrome\Application\chrome.exe unexpectedly exited. Status code was: 0




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值