From d9621edfa93a24b8a20352eb2f58266b2a2d7233 Mon Sep 17 00:00:00 2001 From: William Fox Date: Sat, 13 Feb 2021 11:49:58 -0800 Subject: [PATCH] Readme 1.0.0 (#4) * ++ motivation, support, deploy, depend * added SO post in comments * wip * readme 1.0 --- README.md | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- env.py | 1 + 2 files changed, 90 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 863f674..e55c862 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,92 @@ # Just4Me -An Automation of Von's and Albertson's Just4U Virtual Coupons +[Just4Me](http://wfox-just4me.herokuapp.com/) is website that allows you to run an automation of Von's and Albertson's Just4U Virtual Coupons. -Hosted on Heroku -http://wfox-just4me.herokuapp.com/ +## Motivation + +The motivation behind this project was to automate the virtual coupon clicking that Von's has for their Just4U program. +One day when I was at my parents house my Mom was going through their website clicking each and every coupon on the site just in case she might buy one of the items later. +I sat down and tried to do it a bit faster by hand but it still felt like there would be a better way. +After getting some exposure to [Selenium](https://www.selenium.dev/) I realised I could use it to automate the process. + +Later I wanted to set up the automation to run on a cron job so I wouldn't have to run the automation for my Mom and myself. +However Windows 10 isn't as easy to set up crons as I'd like so I made a website wrapper for the original code and hosted it on [Heroku](https://heroku.com/). + +## Support Me +Help get me off Heroku free dynos + +[![](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/donate?hosted_button_id=U65R5REYQXAR8) + +## Dependencies + +* [selenium](https://pypi.org/project/selenium/) +* [webdriver-manager](https://pypi.org/project/webdriver-manager/) +* [flask](https://pypi.org/project/Flask/) +* [gunicorn](https://pypi.org/project/gunicorn/) +* [Flask-WTF](https://pypi.org/project/Flask-WTF/) +* [email_validator](https://pypi.org/project/email-validator/) + +#### Dependency Installation + +`pip3 install -r requirements.txt` + +## Environment Variables + +``` +SECRET_KEY: A secret key for Flask +TOKEN: A secret token for access control to running the automation +CHROMEDRIVER_PATH: The path to the heroku chrome driver build pack executable +GOOGLE_CHROME_BIN: The path to the heroku chrome driver build pack binary +ENV: Prod/Dev for running locally without heroku buildpacks requirements +``` + +* `ENV` is optional and will default to dev if left unfilled +* `CHROMEDRIVER_PATH` and `GOOGLE_CHROME_BIN` are not required in a dev environment as they're not used for local run + +## How to Run + +#### Pre-Requisites +* [Install the Dependencies](#dependency-installation) +* Set the [Environment Variables](#environment-variables) + * Running via CLI + * `export SECRET_KEY=xxxx` + * `export TOKEN=xxxx` + * Running via `heroku local` + * Populate a `.env` file with the secrets + * ``` + SECRET_KEY=xxxx + TOKEN=xxxx + ``` +#### Running +* Via CLI + * `python app.py` + +* Via `heroku local` + * Windows + * `heroku local -f Procfile.windows` + * Not Windows + * `heroku local` + +## Example + +The website is live at https://wfox-just4me.herokuapp.com/ + +TODO: Add gif of Webdriver running + +## Deployment +The bot is currently deployed on [Heroku](https://heroku.com/) using free dynos. + +The deployment is automated using the [Deploy to Heroku](https://github.com/marketplace/actions/deploy-to-heroku) Action from [AkhileshNS](https://github.com/AkhileshNS). + +## Acknowledgements + +* [SalvatoreTosti/flask-template](https://github.com/SalvatoreTosti/flask-template) + * For getting me started on Heroku + +* Corey Schafer's [Full-Featured Web App](https://www.youtube.com/watch?v=MwZwr5Tvyxo&list=PL-osiE80TeTs4UjLw5MM6OjgkjFeUxCYH) + * For getting me comfortable with a Flask website + +## Next Steps + +* Notify User on Completion/Failed Login +* Fix Selenium wait for element to load/remove sleep calls diff --git a/env.py b/env.py index edf2074..ccaa7e1 100644 --- a/env.py +++ b/env.py @@ -4,6 +4,7 @@ is_prod = env.lower() == 'prod' # region Selenium on Heroku +# https://stackoverflow.com/questions/48723397/how-to-set-path-to-chromedriver-in-heroku-chromedriver-buildpack/56648878 chromedriver_path = os.environ.get('CHROMEDRIVER_PATH') chromedriver_bin = os.environ.get('GOOGLE_CHROME_BIN') if is_prod: