WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 3221225477
This error message...
WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 3221225477
...implies that the ChromeDriver unexpectedly exited.
Status code: 3221225477
As per the documentation in Program exit codes Status Code 3221225477
implies Access violation which indicates that the executed program has terminated abnormally or crashed.
As you are using ChromeDriver / Chrome combination there can be numerous reason for this error. A couple of them are as follows:
- Due to incorrect ChromeDriver path.
You can find a detailed discussion in WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 127
- Due to ChromeDriver / Chrome version mismatch.
You can find a detailed discussion in WebDriverException: Message: Service /content/chromedriver unexpectedly exited. Status code was: -6 with ChromeDriver Google Colab and Selenium
Service chromedriver unexpectedly exited. Status code was: -9
xattr -d com.apple.quarantine /usr/local/bin/chromedriver
/usr/local/bin/chromedriver replace with actual path
WebDriverException: Message: Service /content/chromedriver unexpectedly exited. Status code was: -6 with ChromeDriver Google Colab and Selenium
I have found the answer to the question about why I was getting an error. Please install the chromium-chromedriver and add it to your path variable as well as the bin directory.
This is the fully-fledged solution to the problem of how to scrape data using Selenium on Colab. There is one more method by using PhantomJS but this API has been deprecated by Selenium and hopefully they will remove it in the next Selenium update.
# install chromium, its driver, and selenium
!apt-get update
!apt install chromium-chromedriver
!cp /usr/lib/chromium-browser/chromedriver /usr/bin
!pip install selenium
# set options to be headless, ..
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
# open it, go to a website, and get results
wd = webdriver.Chrome('chromedriver',options=options)
wd.get("https://www.website.com")
print(wd.page_source) # results
This would work for anyone who want to scrape their data on Google Colab and not on your local machine. Please execute the steps as shown sequentially in the same order.
You can find the notebook here https://colab.research.google.com/drive/1GFJKhpOju_WLAgiVPCzCGTBVGMkyAjtk .
Related Topics
Xlsxwriter: How to Open an Existing Worksheet in My Workbook
How to Calculate Range Between the Dataframe Values Using Python
Python Tkinter How to Update a Text Widget in a for Loop
Is There an Easy Way in Python to Wait Until Certain Condition Is True
Python: How to Split a List Based on a Specific Element
How to Maximize a Plt.Show() Window Using Python
Jupyter Notebook Python Nameerror
Calculate Angle (Clockwise) Between Two Points
How to Get the Url of the Active Google Chrome Tab in Windows
Algorithm for Distributing a Number Between Certain Number of Chunks
How to Retrieve Data from Dynamic Table - Selenium Python
How to Resolve Modulenotfounderror: No Module Named 'Google.Colab'
Fillna in Multiple Columns in Place in Python Pandas
Convert Float to Float Time in Python
How to Convert an Integer to Time
Formatting Datetimefield in Django
Plotly Graph Does Not Show When Jupyter Notebook Is Converted to Slides