This README provides instructions on setting up a Python virtual environment, installing required packages, configuring ChromeDriver for Selenium, and running the script using pm2 or screen on a Linux system.
Ensure you have the following installed on your system:
- Python 3
- pip (Python package installer)
- Node.js and npm
pm2(Node process manager)
Run the following commands to install Python3, Xvfb, Node.js, and npm:
sudo apt update
sudo apt install python3 python3-venv python3-pip xvfb nodejs npm -yInstall pm2 globally to manage the process:
sudo npm install -g pm2-
Create a project directory (e.g.,
Main) and navigate into it:mkdir Main && cd Main
-
Set up the virtual environment:
python3 -m venv Main
-
Activate the virtual environment:
source Main/bin/activate
Ensure your requirements.txt file is in the Main folder. Install dependencies with:
python -m pip install -r requirements.txtOpen Chrome and go to chrome://settings/help to find your version of Chrome (e.g., Chrome 115).
-
Go to the ChromeDriver download page.
-
Download the version matching your Chrome version:
wget https://chromedriver.storage.googleapis.com/<version>/chromedriver_linux64.zip
Replace
<version>with the ChromeDriver version (e.g.,115.0.5790.170). -
Extract the downloaded file:
unzip chromedriver_linux64.zip
-
Move ChromeDriver to a directory in your PATH:
sudo mv chromedriver /usr/local/bin/
-
Verify ChromeDriver is installed:
chromedriver --version
To run the script with pm2 using xvfb:
pm2 start "xvfb-run -a python Main/seleniumV2.py" --name VFS- List all processes:
pm2 list - Restart the process:
pm2 restart VFS - Stop the process:
pm2 stop VFS - Delete the process:
pm2 delete VFS - View logs:
pm2 logs VFS
To enable pm2 startup on reboot:
pm2 startup
pm2 save-
Start a new screen session:
screen -S VFS
-
Run the script:
source Main/bin/activate xvfb-run -a python Main/seleniumV2.py -
Detach from the screen session:
- Press
Ctrl + A, thenDto detach without stopping the script.
- Press
-
Reattach to the screen session:
screen -r VFS
-
Terminate the session:
- Reattach to the session, stop the script, then type
exitto close the screen session.
- Reattach to the session, stop the script, then type
This project is licensed under the MIT License.
This `README.md` covers the setup, ChromeDriver installation, and execution options for both `pm2` and `screen`. Let me know if you need additional customization!