In the process of calling selenium's Chrome, I encountered the following error. I found many methods on the Internet but failed to solve it. Finally, I found that it was a version problem of Google Chrome and Chromedriver.
To solve this problem, I used a rough method and re-downloaded selenium, Chrome and Chromedriver
1. Uninstall and download selenium
2. Download Google Chrome browser
Fourth, configure environment variables
1. Uninstall and download selenium
Just type in cmd:
pip uninstall selenium
pip install selenium
2. Download Google Chrome browser
Search and download on Baidu
3. Download Chromedriver
1. First check your Chrome version, click Settings, About Chrome.
2. Download Chromedriver, link: https://chromedriver.storage.googleapis.com/index.html , select the corresponding version, here is 104.0.5112.81, choose one of the following to download according to your computer system.
Fourth, configure environment variables
Put the downloaded Chromedriver file in your python path, here my path is "C:\Users\HP\AppData\Local\Programs\Python\Python310"
Next, find the system properties in the control panel and find the environment variables
Enter New, just copy the path into it.
Then run the code again:
from selenium import webdriver
driver = webdriver.Chrome()
url = 'http://www.baidu.com'
driver.get(url)
normal operation.