# On Ubuntu 18 (LTS)
# This is for a headless installation (xvfb)
# Using Chrome and ChromeDriver
# Through Selenium (python)

# Install dependencies #
sudo apt-get update
sudo apt-get install -y xvfb
sudo apt-get install -y unzip
sudo apt-get install -y libxi6
sudo apt-get install -y libgconf-2-4

# Install Chrome #
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' | sudo tee /etc/apt/sources.list.d/google-chrome.list
sudo apt-get update
sudo apt-get install -y google-chrome-stable

# Install ChromeDriver #
CHROME_DRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`
wget -N http://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip -P ~/test/
unzip ~/test/chromedriver_linux64.zip -d ~/test/
rm ~/test/chromedriver_linux64.zip
sudo mv ~/test/chromedriver /usr/local/bin/chromedriver
sudo chmod +x /usr/local/bin/chromedriver

# Install Selenium #
python3 -m pip install --user selenium

# In python #
from selenium import webdriver
service = webdriver.chrome.service.Service('/usr/local/bin/chromedriver')
service.start()

options = webdriver.ChromeOptions()
options.add_argument('--headless')
options = options.to_capabilities()

driver = webdriver.Remote(service.service_url, options)
driver.get("https://www.example.com")
print(driver.page_source)