Last active
January 27, 2023 06:40
-
-
Save kumorikuma/41e34385f618b7af88565b31208548b6 to your computer and use it in GitHub Desktop.
Environment setup for running an automated headless Chrome browser on Ubuntu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install Chrome, ChromeDriver, and Selenium WebDriver. | |
# ChromeDriver provides an API to control Chrome, and WebDriver facilitates making automated scripts. | |
# References: | |
# https://gist.github.com/ziadoz/3e8ab7e944d02fe872c3454d17af31a5 | |
# https://towardsdatascience.com/how-to-setup-selenium-on-a-linux-vm-cd19ee47d922 | |
# Install Java dependencies for Selenium: | |
sudo apt-get update | |
sudo apt-get install -y unzip openjdk-8-jre-headless xvfb libxi6 libgconf-2-4 | |
# Install Chrome: | |
sudo curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add | |
sudo su -c "echo 'deb http://dl.google.com/linux/chrome/deb/ stable main' >> /etc/apt/sources.list.d/google-chrome.list" | |
sudo apt-get -y update | |
sudo apt-get -y install google-chrome-stable | |
# Install ChromeDriver: | |
# Find which version of Chrome is installed. | |
/usr/bin/google-chrome-stable --version | |
# Based on this version, go to https://chromedriver.chromium.org/downloads to find the download link, then download. | |
wget -N https://chromedriver.storage.googleapis.com/109.0.5414.119/chromedriver_linux64.zip -P ~/ | |
# Unpack files and install to /usr/bin. | |
unzip ~/chromedriver_linux64.zip -d ~/ && rm ~/chromedriver_linux64.zip | |
sudo mv -f ~/chromedriver /usr/local/bin/chromedriver | |
# Adjust permissions. | |
sudo chown root:root /usr/local/bin/chromedriver && sudo chmod 0755 /usr/local/bin/chromedriver | |
# Install python bindings for Selenium: | |
# Install pip if needed: sudo apt install python3-pip | |
pip3 install selenium | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment