0

Im trying to create a webscraper for the first time. The script wont run without a error code.

Tutorial I am using:

https://oxylabs.io/blog/python-web-scraping

I have followed all steps and have undergone further steps via other youtube tutorials but nothing has worked ;(

Error code:

Traceback (most recent call last):
  File "C:\Users\hpy03\PycharmProjects\webtest\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "C:\Users\hpy03\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\hpy03\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 1307, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/hpy03/PycharmProjects/webtest/test_scraping.py", line 5, in <module>
    driver = webdriver.Chrome(executable_path='c:\path\to\windows\webdriver\executable.exe')
  File "C:\Users\hpy03\PycharmProjects\webtest\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
    self.service.start()
  File "C:\Users\hpy03\PycharmProjects\webtest\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'executable.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
Omnikar
  • 307
  • 2
  • 9
Hans
  • 11
  • 1
    You need to replace "c:\path\to\windows\webdriver\executable.exe" with the real path to the webdriver that you installed. It may vary. – mr_mooo_cow Mar 18 '21 at 16:42

1 Answers1

0

It seems like you haven't referenced chromedriver properly. If you run chromedriver -v in Command Prompt, and get a version back, then just remove the executable_path=... from your code:

Before:

driver = webdriver.Chrome(executable_path='c:\path\to\windows\webdriver\executable.exe')

After:

driver = webdriver.Chrome()

Otherwise, you can place chromedriver.exe in the same folder as your code, and reference it like so:

driver = webdriver.Chrome(executable_path='./chromedriver.exe')

If you don't have chromedriver.exe, then see here.

marsnebulasoup
  • 2,530
  • 2
  • 16
  • 37