成功解决BUG:selenium.common.exceptions.WebDriverException: Message: ‘chromedriver’ executable needs to be in PATH.
Article Directory
Abnormal Interpretation
When using Python to operate selenium, the following error occurs:
selenium.common.exceptions.WebDriverException: Message: ‘chromedriver’ executable needs to be in PATH
The translation of the error into Chinese is:
chromedriver.exe
The file was not found, and the directory corresponding to the file needs to be configured.
The actual encoding error is shown in the image below.
Solutions
This BUG is caused by Selenium being unable to find the executable file of the Chrome driver (chromedriver).
The solution is just to specify the path in the code.
driver = webdriver.Chrome(r'G:\chromedriver_win32\chromedriver.exe')
error recurrence
You can enter the following code in the Python file, and the error shown in the title of this article will appear:
from selenium.webdriver.chrome.options import Options
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
def get_data(url):
driver = webdriver.Chrome(r'G:\chromedriver_win32\chromedriver.exe')
# url = 'https://www.jd.com'
driver.get(url)
print(driver.title)
get_data('https://www.jd.com')
other learning materials
- "Snowball Learning Python" column and physical book: https://dream.blog.csdn.net/article/details/131268344
- 《100 examples of reptiles》: https://blog.csdn.net/hihell/category_9280209.html
- 《Python爬虫120》:https://blog.csdn.net/hihell/category_11079529.html