-2

I am just starting to learn web scraping with selenium. I am not sure why I am getting the following errors. I have shared the image below. The following code seems to not work.

chrome_path = r"\\Users\\prateek\\Desktop\\MSc\\MWA\\chromedriver.exe"

browser = webdriver.Chrome(chrome_path)

 # the url we want to open
url = u'https://www.currys.co.uk/gbuk/phones-broadband-and-sat-nav/mobile-phones-and-accessories/mobile-phones/apple-iphone-8-64-gb-space-grey-10168742-pdt.html?intcmpid=display~RR'

 # the browser will start and load the webpage
 browser.get(url)

There is more to it but this doesn't seem to work Error I'm getting Error I'm getting

paddy
  • 123
  • 1
  • 2
  • 13
  • 2
    Please don't post images of errors. Take the time to copy, past, and format the error. Also, there must be dozens of "chromedriver must be in path" questions on this site. I suggest you do a bit more research, and share what you've learned. – Bryan Oakley Jan 23 '18 at 16:56
  • Error itself describing everything – Pradeep hebbar Jan 23 '18 at 17:27

3 Answers3

1

Python's r"" literal syntax escapes all your slashes automatically, which is why it's preferred for things like file paths.

Try using

chrome_path = r"\Users\prateek\Desktop\MSc\MWA\chromedriver.exe"

Hans Z
  • 4,664
  • 2
  • 27
  • 50
  • Also, executables on Macs don't usually have `.exe` extensions, do you have the right version of chromedriver? – Hans Z Jan 23 '18 at 17:02
  • oh. That might be the issue. Don't think the .exe extension is the issue. And @Hans Z, I did try that but it doesn't seem to work. Gives the same error – paddy Jan 23 '18 at 17:10
0

From chromedriver getting started, in the Setup section, is indicated:

Help WebDriver find the downloaded ChromeDriver executable

Any of these steps should do the trick:

  1. include the ChromeDriver location in your PATH environment variable
  2. include the path to ChromeDriver when instantiating webdriver.Chrome (see sample below)

You are trying to use the 2 option but you are passing the path of a wrong file (.exe file, sure, is not executable in macOS).

So, first of all you have to download (from here ) the correct chromedriver.

Assuming you are using the current latest chrome version as browser, you have to download the chromedriver_mac64.zip from the 2.35 (https://chromedriver.storage.googleapis.com/index.html?path=2.35/), extract it and insert the path to the extracted executable in your code.

For example:

driver = webdriver.Chrome(executable_path=r'/yourPath2/chromedriver')
driver.get("https://www.currys.co.uk/gbuk/phones-broadband-and-sat-nav/mobile-phones-and-accessories/mobile-phones/apple-iphone-8-64-gb-space-grey-10168742-pdt.html?intcmpid=display~RR")

Be careful about your chrome browser version, because might not be supported by the chromedriver. You can know this following this release notes.

Community
  • 1
  • 1
Davide Patti
  • 3,391
  • 2
  • 18
  • 20
  • Hi, I have done that. I downloaded the chromedriver_mac64.zip and it still gives me the same error. Cant figure out why its doing that. – paddy Jan 23 '18 at 19:20
  • You have to extract the .zip and insert the path to the extracted file in your code – Davide Patti Jan 23 '18 at 19:56
0

Using chromedriver binary to initialize Chrome Web Browser on MAC OSX you need to pass the argument executable_path along with the absolute path of the chromedriver binary within single quotes \ preceded by the raw switch r as follows :

driver = webdriver.Chrome(executable_path=r'\Users\prateek\Desktop\MSc\MWA\chromedriver')
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352