Python script for scraping and mailing price drops of Oculus Rift S headset from different sources.
The application consists of two basic components:
- Web-scraper - based on
BeautifulSoup4
andrequests
libraries. Uses functions defined infunctions.py
. Currently scrapes only the official oculus store and amazon.de. - Mailing module - function
send_prices
creates a secure connection with Gmail's SMTP server using Python's standardsmtplib
library, creates a multipart message, encrypts the attachment and sends the e-mail as specified.
- Clone this repository
- Navigate to the root directory and run:
python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt
- Open
venv/bin/activate
and add the following statements:
export OCULUS_PASS=put_your_app_specific_pass_here
export OCULUS_MAIL=put_your_email_here
OCULUS_PASS
is the Gmail's application specific password aquired via your gmail account.
OCULUS_MAIL
is the sender's/receiver's e-mail address.
- Deactivate and activate the virtualenv again
- Run
python3 main.py
and let the script do it's work. - URLs and prices from each source are stored as
key:value
pairs inprices.json
.
For the purpose of automating the program, author has a set up cron job. In order to replicate it, first run:
chmod +x path/to/oculus-price-mailing/cron_wrapper.sh
The shell wrapper is now an executable.
Now run crontab -e
and add the following:
0 * * * * /absolute/path/to/oculus-price-mailing/cron_wrapper.sh >> /absolute/path/to/oculus-price-mailing/cron.log 2>&1
This will run the bash wrapper script every hour.
Adjust the absolute paths so that they reflect the actual location of the repository on your local machine. You can also adjust the frequency of the cron job.
The cron.log
will be created at first execution of the script. It's contents will be updated at each consecutive execution.
- Come up with more sources for price scraping and construct functions around them
- Dockerize the app