Reputation: 23
I'm following a scraping tutorial from GeeksForGeeks below: https://colab.research.google.com/drive/14kXYQCSGVye4bBKKExtuHOeq32bc4xbW?usp=sharing#scrollTo=UjB8J1L8s6kT
I'm working on a Macbook Pro in Google Colab via Chrome.
When I get to the 4th command block where the path and driver are defined I get an error saying
<ipython-input-33-bb59bfe38590>:2: DeprecationWarning: executable_path has been deprecated, please pass in a Service object
driver = webdriver.Chrome(PATH)
And
During handling of the above exception, another exception occurred:
WebDriverException Traceback (most recent call last)
/usr/local/lib/python3.8/dist-packages/selenium/webdriver/common/service.py in _start_process(self, path)
211 except OSError as err:
212 if err.errno == errno.ENOENT:
--> 213 raise WebDriverException(
214 f"'{os.path.basename(self.path)}' executable needs to be in PATH. {self.start_error_message}"
215 )
WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://chromedriver.chromium.org/home
What does this mean? Do I need to link to webdriver on my local mac drive? Currently the command in the tutorial is:
PATH = "/Users/Edu/Desktop/VENV/chromedriver"
driver = webdriver.Chrome(PATH)
driver.get(url)
Do I need to replace this with the path to chromedriver in my files? I tried replacing the path above with the below but it doesn't change anything:
/Users/KD/Downloads/chromedriver
Tried the command below from the tutorial linked here: https://colab.research.google.com/drive/14kXYQCSGVye4bBKKExtuHOeq32bc4xbW?usp=sharing#scrollTo=UjB8J1L8s6kT
PATH = "/Users/Edu/Desktop/VENV/chromedriver"
driver = webdriver.Chrome(PATH)
driver.get(url)
Upvotes: 0
Views: 434
Reputation: 33361
You need to use Service
.
The following works:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
options = Options()
options.add_argument("start-maximized")
webdriver_service = Service('C:\webdrivers\chromedriver.exe')
driver = webdriver.Chrome(service=webdriver_service, options=options)
url = 'your_link'
driver.get(url)
Upvotes: 1