Skip to content

Latest commit

 

History

History
83 lines (73 loc) · 2.53 KB

README.md

File metadata and controls

83 lines (73 loc) · 2.53 KB

Amazon Price Tracker using Python, Selenium and AWS EC2

This automated Price Tracker for amazon product is built using Python. It allows Tracking price changes and sending email alerts once the desired price is reached priceTracker

Steps

  • getting the link from Amazon website and locating elements: product name and price
  • Fetching the element using selenium syntax See documentation
  • Checking if the price meets the budget
  • Sending an e-mail alert using smtplib

Requirements and Setup

Chromedriver

Download and installation

Virtual Environment Setup

python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt

Requirements Installation

pip install -r requirements.txt

Runnig Price Tracker Script

python3 scraper.py

Scheduling our task with AWS and Cronjob:

The goal is to trigger the script (the price tracker) daily

Launching an EC2 instance and connecting to it

Please refer to this documentation

Accessing the EC2 instance

Open your local terminal, go to the directory where your private key is stored and run the following command :

ssh -i /path/my-key-pair.pem ec2-user@my-instance-public-dns-nae

Installing tools on our instance

Python & pip

sudo yum install python37
curl -O https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py --user

Chrome Driver & chrome

cd/tmp/
wget https://chromedriver.storage.googleapis.com/2.37/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
sudo mv chromedriver /usr/bin/chromedriverchromedriver --version
curl https://intoli.com/install-google-chrome.sh | bash
sudo mv /usr/bin/google-chrome-stable /usr/bin/google-chrome
google-chrome --version && which google-chrome

Selenium

pip3 install selenium

Moving our script to EC2 instance

scp -i /path/my-key-pair.pem python_file.py ec2-user@my-instance-public-dns-nae:~

scheduling with Crontab

Connect to EC2 and edit crontab file

crontab -e

Adding cron expression

The syntax to run the script every day at 8 am is:

0 8 * * *  python3 /path_file/file_name.py

Check this crontab guide