gpt4 book ai didi

python - Selenium Chromedriver 错误代码 : 3221225477

转载 作者:太空宇宙 更新时间:2023-11-03 21:04:00 24 4
gpt4 key购买 nike

在 python 3 中使用 selenium 启动 chromedriver 时,加载时一切似乎都顺利至少一秒钟,但随后弹出此错误消息:

Traceback (most recent call last):
File "C:\...\Selenium\UsingChrome.py3", line 15, in <module>
driver = webdriver.Chrome(executable_path="chromedriverwin32.exe")
File "c:\Users\...\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
self.service.start()
File "c:\Users\...AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\common\service.py", line 98, in start
self.assert_process_still_running()
File "c:\Users\...\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\common\service.py", line 111, in assert_process_still_running
% (self.path, return_code)
selenium.common.exceptions.WebDriverException: Message: Service chromedriverwin32.exe unexpectedly exited. Status code was: 3221225477

我当前的代码是:

from selenium import webdriver
import time, os

options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument("--test-type")
options.binary_location = 'chromedriver.exe'
driver = webdriver.Chrome(chrome_options=options)
driver.get('https://python.org')

...我尝试使用 chromedriver 位置的绝对路径,但这仍然没有帮助(chromedriver.exe 文件位于与脚本相同的目录中)

  • 我在 Windows 10 笔记本电脑上的 python 3.6.5 上运行此程序

  • 我已经在网上搜索了大约 3 个小时,但没有遇到与我遇到的相同的错误状态代码。

最佳答案

好吧,这真的很奇怪。Chromedriver selenium 在交互式 shell 中启动时工作得很好,但在执行脚本时却不行。在我的机器上,我设置了一些批处理文件,这些文件在执行 python 脚本时执行(运行 Ansicon.exe 之类的东西以在 cmd 中显示颜色),并在使用命令“python3 script.py”运行 python 脚本后执行' 它工作完美......所以我不确定为什么以前没有,但无论如何,现在已经修复了。

  • 但如果有人确实有答案,我很想知道为什么会发生这种情况......

我的代码现在是:

from selenium import webdriver
browser = webdriver.Chrome()
while 1: pass # wait forever just to let chromedriver be interactive

要启动的批处理文件只有一行:

python3 script.py

关于python - Selenium Chromedriver 错误代码 : 3221225477,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55545293/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com