0

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)
Prophet
  • 32,350
  • 22
  • 54
  • 79
Kimberley
  • 23
  • 5

1 Answers1

1

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)
Prophet
  • 32,350
  • 22
  • 54
  • 79
  • Thank you Prophet! Is my link then the link to my local drive or the link to the page I'm meant to be scraping? If I do either I keep getting the same error so tried pip installing selenium but keep getting this error: WebDriverException: Message: 'C:\webdrivers\chromedriver.exe' executable needs to be in PATH – Kimberley Jan 03 '23 at 12:36
  • In my example `C:\webdrivers\chromedriver.exe` is the actual path to `chromedriver.exe` file on my computer. I do not know where is it located on your PC. and `your_link` is the URL you will wish to open, for example https://www.google.com/ – Prophet Jan 03 '23 at 12:44
  • Thank you for explaining, much appreciated :) I do get a new error now saying "ModuleNotFoundError: No module named 'selenium'". Would this be a case where the selenium package needs to be pip installed? – Kimberley Jan 03 '23 at 12:59
  • 1
    https://stackoverflow.com/questions/31147660/importerror-no-module-named-selenium – Prophet Jan 03 '23 at 13:19
  • 1
    But there are more possible causes for that – Prophet Jan 03 '23 at 13:19