简体   繁体   English

Chromedriver.exe已停止工作-python

[英]Chromedriver.exe has stopped working - python

I keep getting this error: https://sites.google.com/a/chromium.org/chromedriver/help/chromedriver-crashes 我不断收到此错误: https : //sites.google.com/a/chromium.org/chromedriver/help/chromedriver-crashes

I get it when running the command: 我在运行命令时得到它:

python Web.py

However when I go into the file and run the lines 1 by 1, I don't get the error. 但是,当我进入文件并以1行1行运行时,我没有得到该错误。 However I always get the error when the Web.py file has finished. 但是,当Web.py文件完成时,我总是会收到错误消息。 When I run the lines 1 by 1, it's very basic things but i feel like I"m not ending my script correctly. 当我从1开始运行第1行时,这是非常基本的事情,但是我觉得我没有正确结束脚本。

import selenium
from selenium.webdriver.common.keys import Keys
import time
from selenium import webdriver
driver = webdriver.Chrome()
driver.get('espn.com')

I want the window with espn.com to stay on the screen, not quit when the script has finished. 我希望espn.com的窗口保留在屏幕上,而不是在脚本完成后退出。

I'm running this on Python. 我在Python上运行它。 I can share my setup, maybe that's something I did incorreclty but any help would be appeciated. 我可以分享我的设置,也许这​​是我做的不正确,但是任何帮助都会感激不尽。

You're passing an invalid url. 您传递的网址无效。

You need to pass the url like this: 您需要像这样传递网址:

driver.get("http://www.espn.com")

This might work in your browser, but it won't with selenium. 这可能在您的浏览器中有效,但不适用于硒。 Type in "espn.com" in your browser and then copy / paste the url and you'll see that it's actually the above url. 在浏览器中输入“ espn.com”,然后复制/粘贴该网址,您会发现它实际上是上面的网址。

You should also specify the "chromedriver.exe" path. 您还应该指定“ chromedriver.exe”路径。

You are getting this error because you had not installed the chrome driver for selenium on your Machine. 由于未在计算机上安装硒的Chrome驱动程序,因此出现此错误。 Selenium by default provides the driver for Firefox so when you use the webdriver for Firefox, it won't rise any error. Selenium默认提供Firefox的驱动程序,因此当您将Webdriver用于Firefox时,它不会出现任何错误。 To resolve this issue with Chrome you can download the Chrome webdriver from here . 要解决Chrome的此问题,您可以从此处下载Chrome网络驱动程序。

and you can specify the driver as 您可以将驱动程序指定为

from selenium import webdriver
d = webdriver.Chrome(executable_path='<your Chrome driver path>')

Adding to what @Pythonista said , it's better if you keep the URL as a raw string than a normal string 添加@Pythonista所说的内容,最好将URL保留为原始字符串,而不是普通字符串

driver.get(r'http://www.espn.com')

so that it won't take the slash as an escape sequence in few cases. 因此在少数情况下不会将斜线作为转义序列。

Hope it helps. 希望能帮助到你。

Try to update chrome and get updated/latest chrome driver, recently chrome made several updates in its driver you can download the last one from the link below: 尝试更新chrome并获取更新/最新的chrome驱动程序,最近chrome在其驱动程序中进行了几次更新,您可以从下面的链接下载最后一个:

https://chromedriver.storage.googleapis.com/2.27/chromedriver_win32.zip https://chromedriver.storage.googleapis.com/2.27/chromedriver_win32.zip

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 chromedriver.exe停止工作问题 - chromedriver.exe stopped working issue chromedriver.exe 问题与 python - issue with chromedriver.exe with python Python WebDriver - ChromeDriver.exe 不工作,要求我提供一些权限(!?) - Python WebDriver - ChromeDriver.exe not working asking me for some permissions(!?) WebDriverException:服务 U:/Scraping/chromedriver.exe 意外退出。 状态代码为:1 使用 Chrome 和 Python 时 - WebDriverException: Service U:/Scraping/chromedriver.exe unexpectedly exited. Status code was: 1 while working with Chrome and Python 是否可以在 python 运行时检查 chromedriver.exe 版本? - Is it possible to check chromedriver.exe version at runtime in python? 有没有办法在 Python program.exe(通过 pyinstaller)中包含“chromedriver.exe”? - Is there a way to include the “chromedriver.exe” within a Python program .exe (via pyinstaller)? 如何将 chromedriver.exe 添加到 PATH? - How to add chromedriver.exe to PATH? Selenium WebDriverException 'chromedriver.exe' 需要在 PATH 中 - Selenium WebDriverException 'chromedriver.exe' needs to be in PATH colab 中的 chromedriver.exe 没有权限 - None permission for chromedriver.exe in colab Pyinstaller 在运行 .exe 时给出“'chromedriver.exe' 可执行文件需要在 PATH 中”,但实际的 python 脚本工作正常 - Pyinstaller gives “ 'chromedriver.exe' executable needs to be in PATH” when the .exe is ran, but the actual python script works fine
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM