Setup Script for Git, Python, Playwright, Selenium, Firefox, and Chrome WebDriver on Android - https://blog.lowlevelforest.com/
This repository contains a bash script to automatically check and install the necessary tools for web scraping and automation on an Android device using Termux. The script ensures that Git, Python 3.12, Playwright, Selenium, Firefox, and Chrome WebDriver are installed and configured correctly.
- Termux app installed on your Android device.
- An internet connection for downloading packages and dependencies.
- Root access may be required for certain operations.
- Installs and configures Git, Python 3.12, Playwright, Selenium, Firefox, and Chrome WebDriver.
- Automatically handles dependencies and installs the necessary packages.
- Verifies and upgrades the tools to the latest versions.
Before running the script, make sure you have the following installed:
- Termux: Install from Termux on F-Droid or Google Play.
- GitHub Account: To clone this repository and upload changes.
If you haven't already installed Termux, download and install it from the Google Play Store or F-Droid.
Open Termux and run the following command to clone this repository:
git clone https://github.com/coffeecms/android_auto_install_playwright_selenium.git
Navigate into the cloned directory:
cd repository-name
Ensure the script is executable by running the following command:
chmod +x setup_script.sh
Execute the script to install the required tools:
./setup_script.sh
The script will automatically check and install:
- Git
- Python 3.12
- Playwright
- Selenium
- Firefox
- Chrome WebDriver
After the script finishes running, you can verify that all tools have been installed successfully by running:
git --version
python3 --version
pip show playwright
pip show selenium
chromium --version
You should see the version details for each tool.
The script first checks if Git is installed using:
if ! command -v git &> /dev/null
then
pkg update -y && pkg install git -y
fi
If Git is not found, it installs it using pkg install git
.
It checks if Python 3.12 is installed:
if ! command -v python3 &> /dev/null
then
pkg install python -y
fi
If Python is missing, it installs it.
Playwright and Selenium are installed using pip
:
pip install playwright
pip install selenium
The script will install these dependencies if they are not already installed.
-
Firefox is installed using:
pkg install firefox -y
-
Chromium (Chrome) is installed with:
pkg install chromium -y
After installing Chromium, the script checks the version of Chromium and installs the corresponding ChromeDriver using:
wget https://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
chmod +x chromedriver
mv chromedriver /usr/local/bin/
Once the setup is complete, you can use Playwright and Selenium to automate web tasks in Python. Below is an example Python script using Selenium and Playwright.
from selenium import webdriver
# Set up Chrome WebDriver
driver = webdriver.Chrome()
# Open a webpage
driver.get('https://www.example.com')
# Print the title of the page
print(driver.title)
# Close the browser
driver.quit()
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page()
page.goto('https://www.example.com')
print(page.title())
browser.close()
-
Issue: Playwright fails to launch browser
Make sure you have installed the correct browser binaries using Playwright by runningplaywright install
. -
Issue: Missing dependencies
Ensure your Termux installation is up to date by runningpkg update
before running the script.
If you'd like to contribute to this project, feel free to fork the repository, make changes, and create a pull request. Contributions are welcome!
This project is licensed under the MIT License - see the LICENSE file for details.