Ubuntu install Selenium

Ubuntu install Selenium

Most sites can be crawled with simple wget in Bash but some are loaded at runtime using Javascripts. These sites cannot be crawled using simple wget in Bash. You’ll need something like Selenium.

To install Selenium, Firefox and xvfb. Run these commands.

sudo apt update
sudo apt install python-pip firefox xvfb -y
echo export DISPLAY=:99|sudo tee -a /etc/environment
pip install selenium

Download geckodriver. Extract it and move to /usr/bin/

wget https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz
tar -xzvf geckodriver-v0.24.0-linux64.tar.gz
sudo mv geckodriver /usr/bin/

Login as root, and set to run xvfb at reboot.

sudo su
crontab -e
@reboot Xvfb :99 -ac
reboot now

Create a simple python script to test if your installation is successful.

vim test.py
from selenium import webdriver
driver = webdriver.Firefox()
try:
  driver.get('https://www.bing.com')
  print driver.title
finally:
  driver.quit()
python test.py

Ubuntu setup React Native

Ubuntu setup React Native

In this post, I am setting up React Native in Ubuntu 18.04. Before we begin, we need to check if we have all the prerequisites. Once all prerequisites are installed, we will proceed with setting up a React Native project. Finally running the app in Expo app in iOS and Android.

Java Development Kit (JDK)

Check your JDK version to see if you currently have JDK installed. In my screenshot, I do not have JDK installed.

# Check if you have JDK installed
javac -version

# Run the below command to install JDK
sudo apt install openjdk-8-jdk-headless
ubuntu setup react native
JDK not found in my Ubuntu 18.04.

Python

Check your python version to see if you had python installed.

# Check your python version
python -v

# Run the below command to install python
sudo apt install python
ubuntu setup react native
Python not found in my Ubuntu 18.04.

Node.js and npm

Check your Node.js and npm version to see if you had it installed.

# Check Node.js version
node -v

# Check npm version
npm -v

# Install Node.js
sudo apt install nodejs

# Install npm
sudo apt install npm
ubuntu setup react native
Node.js and npm not found in my Ubuntu 18.04.

Create React Native project

# This is for generating React Native project files
sudo npm install -g create-react-native-app

# Create a new project MyReactNativeApp
sudo create-react-native-app MyReactNativeApp
ubuntu setup react native
Successfully created MyReactNativeApp project.

Setting Permissions

Earlier we created the React Native project with sudo because it needs to write some files into /usr/local/ directory. Now we need to change the project files owner back to myself.

# Changeing the owner from root to myself
cd ~
sudo chown -R kevinfoo:kevinfoo .expo/
sudo chown -R kevinfoo:kevinfoo MyReactNativeApp/

Running the app

cd MyReactNativeApp
expo start
ubuntu setup react native
Successfully starting the app.
ubuntu setup react native
Install the Expo client in iOS or Android and scan the QR code to run it.

Expo client

Expo client is available for download at their official site.