From 8d602f50b5a97df4b70fb5d645f163046f70c264 Mon Sep 17 00:00:00 2001 From: keoy7am Date: Tue, 3 Mar 2020 03:35:11 +0800 Subject: [PATCH] add install scripts --- chromedriver-install.sh | 21 +++++++++++++++++++++ geckodriver-install.sh | 26 ++++++++++++++++++++++++++ install.sh | 13 +++++++++++++ requirements.txt | 2 ++ 4 files changed, 62 insertions(+) create mode 100644 chromedriver-install.sh create mode 100644 geckodriver-install.sh create mode 100644 install.sh create mode 100644 requirements.txt diff --git a/chromedriver-install.sh b/chromedriver-install.sh new file mode 100644 index 0000000..4bf63a6 --- /dev/null +++ b/chromedriver-install.sh @@ -0,0 +1,21 @@ +#!/bin/sh +# download and install latest geckodriver for linux or mac. +# required for selenium to drive a firefox browser. + +install_dir="/usr/local/bin" +version=$(wget -qO- https://chromedriver.storage.googleapis.com/LATEST_RELEASE) +if [[ $(uname) == "Darwin" ]]; then + url=https://chromedriver.storage.googleapis.com/$version/chromedriver_mac64.zip +elif [[ $(uname) == "Linux" ]]; then + url=https://chromedriver.storage.googleapis.com/$version/chromedriver_linux64.zip +else + echo "can't determine OS" + exit 1 +fi +echo "url => $url" +curl -o chromedriver.zip "$url" +unzip chromedriver.zip +rm -f chromedriver.zip +chmod +x chromedriver +sudo mv chromedriver "$install_dir" +echo "installed chromedriver binary in $install_dir" \ No newline at end of file diff --git a/geckodriver-install.sh b/geckodriver-install.sh new file mode 100644 index 0000000..838ed66 --- /dev/null +++ b/geckodriver-install.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# download and install latest geckodriver for linux or mac. +# required for selenium to drive a firefox browser. + +install_dir="/usr/local/bin" + +# fetch latest version download url +json=$(curl -s https://api.github.com/repos/mozilla/geckodriver/releases/latest) +if [[ $(uname) == "Darwin" ]]; then + url=$(echo "$json" | jq -r '.assets[].browser_download_url | select(contains("macos"))') +elif [[ $(uname) == "Linux" ]]; then + url=$(echo "$json" | jq -r '.assets[].browser_download_url | select(contains("linux64"))') +else + echo "can't determine OS" + exit 1 +fi + +# if you don't wanna use the latest version +# you can also comment out the section to get the latest version +# and set $url as tested version + +# $url = https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-linux64.tar.gz #set $url as tested version +sudo curl -s -L "$url" | tar -xz +sudo chmod +x geckodriver +sudo mv geckodriver "$install_dir" +echo "installed geckodriver binary in $install_dir" \ No newline at end of file diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..c8a3df7 --- /dev/null +++ b/install.sh @@ -0,0 +1,13 @@ +#!/bin/bash +sudo apt update +sudo apt install python3-pip curl jq -y +sudo pip3 install -r requirements.txt # install python3 dependency packages +# ===== Ubuntu 18.04 LTS need this ===== +sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py +sudo python3 get-pip.py --force-reinstall +sudo rm get-pip.py # remove it after re-install +# ====================================== + +# fetch from https://gist.github.com/diemol/635f450672b5bf80420d595ca0016d20 +#sudo bash geckodriver-install.sh +#sudo bash chromedriver-install.sh \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..fdd089e --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +selenium +requests \ No newline at end of file