半肾
精华
|
战斗力 鹅
|
回帖 0
注册时间 2011-6-20
|
用python折腾了下selenium自动化,chrome和chromedriver版本都是96.0.4664.45,设置了环境变量,运行代码自动打开一个“date.;”窗口,过几秒就自动关闭了。
放狗找解决方案,都说chromedriver版本不对,可是我这个已经是对的了,stackoverflow上也有很多提问的,没找到个能解决的。这问题到底咋整?
代码如下:
- from selenium import webdriver
- chrome_options = webdriver.ChromeOptions()
- chrome_options.add_experimental_option("excludeSwitches", ['enable-automation'])
- chrome_path = r'D:\Program Files\Chrome_96.0.4664.45_64bit_Portable\App\chromedriver.exe'
- driver = webdriver.Chrome(chrome_path, options=chrome_options)
- url = 'http://www.baidu.com/'
- driver.get(url)
复制代码- Traceback (most recent call last):
- File "F:/Python练习/爬虫/se学习.py", line 8, in <module>
- driver = webdriver.Chrome(chrome_path, options=chrome_options)
- File "C:\Users\Luke\anaconda3\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 76, in __init__
- RemoteWebDriver.__init__(
- File "C:\Users\Luke\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
- self.start_session(capabilities, browser_profile)
- File "C:\Users\Luke\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
- response = self.execute(Command.NEW_SESSION, parameters)
- File "C:\Users\Luke\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
- self.error_handler.check_response(response)
- File "C:\Users\Luke\anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
- raise exception_class(message, screen, stacktrace)
- selenium.common.exceptions.WebDriverException: Message: unknown error: unable to discover open pages
- 进程已结束,退出代码为 1
复制代码
|
|