For some context, I'm using Google Collab to try to make a webscraper, and for that I want to use selenium. But I can't seem to set up the web driver properly. Google uses Ubuntu servers I believe.
This is my first time trying to selenium so I'm not sure what I'm looking for or doing wrong.
Here is the installation of selenium and geckodriver.
!pip install selenium
!wget https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz
!tar -xvzf geckodriver*
!chmod +x geckodriver
!sudo mv geckodriver /usr/local/bin/
Here is the code I'm attempting to run
driver = webdriver.Firefox()
driver.get(product_link)
driver.implicitly_wait(5)
Here is the error I'm getting.
WebDriverException Traceback (most recent call last)
<ipython-input-11-ef677185e35a> in <cell line: 4>()
2 product_link = base_url + links[0]
3
----> 4 driver = webdriver.Firefox()
5 driver.get(product_link)
6 driver.implicitly_wait(5)
2 frames
/usr/local/lib/python3.10/dist-packages/selenium/webdriver/common/service.py in assert_process_still_running(self)
108 return_code = self.process.poll()
109 if return_code:
--> 110 raise WebDriverException(f"Service {self._path} unexpectedly exited. Status code was: {return_code}")
111
112 def is_connectable(self) -> bool:
WebDriverException: Message: Service /usr/local/bin/geckodriver unexpectedly exited. Status code was: 1
What is status code 1 mean? The only other result I could find for the status 1 error was a reddit that's been private.
This error message...
WebDriverException: Message: Service /usr/local/bin/geckodriver unexpectedly exited. Status code was: 1
...implies that the GeckoDriver was unable to initiate/spawn a new Browsing Context i.e. firefox session.
Your main issue is the incompatibility between the version of the binaries as you are using as GeckoDriver version 0.24.0 which supported Firefox v57 to v79 is quite old and ancient now.
So there is a clear mismatch between GeckoDriver v0.24.0 and the current Firefox Browser v114.0.2 which is aptly supported by GeckoDriver v0.33.0
You need to download GeckoDriver v0.33.0 as:
!wget https://github.com/mozilla/geckodriver/releases/download/v0.33.0/geckodriver-v0.33.0-linux64.tar.gz
A couple of relevant documentations: