Skip to content

Instantly share code, notes, and snippets.

@kikegarcia
Forked from xiaol825/install.txt
Last active June 30, 2022 11:49
Show Gist options
  • Save kikegarcia/36aebc413537905949221a09b9c9f52d to your computer and use it in GitHub Desktop.
Save kikegarcia/36aebc413537905949221a09b9c9f52d to your computer and use it in GitHub Desktop.
How to install Chrome, ChromeDriver and Selenium on CentOS. Plus a sample scraping script.
#!/bin/bash
nohup xvfb-run --server-args="-screen 0 1920x1080x24" java -Dwebdriver.chrome.driver="/usr/local/bin/chromedriver" -Dwebdriver.chrome.whitelistedIps="" -jar /opt/selenium-server-standalone.jar -role hub &
sleep 10
nohup xvfb-run --server-args="-screen 0 1920x1080x24" java -Dwebdriver.chrome.driver="/usr/local/bin/chromedriver" -Dwebdriver.chrome.whitelistedIps="" -jar /opt/selenium-server-standalone.jar -role node -hub http://10.160.1.5:4444/grid/register &
#!/usr/bin/env bash
# Comando para ejecutar selenium
# xvfb-run --server-args="-screen 0 1920x1080x24" java -Dwebdriver.chrome.driver="/usr/local/bin/chromedriver" -Dwebdriver.chrome.whitelistedIps="" -jar /opt/selenium-server-standalone.jar -debug
# Obtener captura de pantalla
# xwd -display :99 -root -out /tmp/pic
# Versions
CHROME_DRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`
SELENIUM_STANDALONE_VERSION=3.9.1
SELENIUM_SUBDIR=$(echo "$SELENIUM_STANDALONE_VERSION" | cut -d"." -f-2)
USER=egarcia
# Remove existing downloads and binaries so we can start from scratch.
sudo yum remove google-chrome-stable
rm ~/selenium-server-standalone-*.jar
rm ~/chromedriver_linux64.zip
sudo rm /usr/local/bin/chromedriver
sudo rm /usr/local/bin/selenium-server-standalone.jar
# Install dependencies.
sudo yum update
sudo yum install -y unzip java-1.8.0-openjdk-headless xorg-x11-server-Xvfb libxi6 libgconf-2-4
# Install Chrome.
sudo vi /etc/yum.repos.d/google-chrome.repo
# Make sure you have below info in the file(remove hash).
#[google-chrome]
#name=google-chrome
#baseurl=http://dl.google.com/linux/chrome/rpm/stable/x86_64
#enabled=1
#gpgcheck=1
#gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub
sudo yum install -y google-chrome-stable
# Install ChromeDriver.
wget -N https://chromedriver.storage.googleapis.com/70.0.3538.16/chromedriver_linux64.zip -P ~/
unzip ~/chromedriver_linux64.zip -d ~/
rm ~/chromedriver_linux64.zip
sudo mv -f ~/chromedriver /usr/local/bin/chromedriver
sudo chown root:root /usr/local/bin/chromedriver
sudo chmod 0755 /usr/local/bin/chromedriver
# Install Selenium.
wget -N http://selenium-release.storage.googleapis.com/$SELENIUM_SUBDIR/selenium-server-standalone-$SELENIUM_STANDALONE_VERSION.jar -P ~/
sudo mv -f ~/selenium-server-standalone-$SELENIUM_STANDALONE_VERSION.jar /opt/selenium-server-standalone.jar
sudo vim /etc/rc.local
# /home/$USER/boot_selenium.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment