Giter Site home page Giter Site logo

amazon-alert's Introduction

External Libraries

matplotlib
numpy
datetime
smtplib
amazonapi

Required Accounts

To do this you'll need two free accounts
1. Amazon Web Services
2. Google Mail

Sgn up for a product advertising account after you create your AWS credentials

Code Examples

Run Once for Initial Setup

from AmazonAlert import addProduct, dailyScan

# ----- Gmail Credentials -----------

# This gives your script access to your gmail account, may want to use a throwaway
# Make sure "Allow Access To Less Secure Apps" is turned on in gmail settings
EMAIL_SELF = '[email protected]'
EMAIL_PASSWORD = 'yourpassword'    

# If using a throwaway, adjust EMAIL_TO to your real email!
EMAIL_FROM = EMAIL_SELF     
EMAIL_TO = EMAIL_SELF
EMAIL_CREDENTIALS = [EMAIL_SELF, EMAIL_PASSWORD, EMAIL_FROM, EMAIL_TO]
 
# ----- Amazon Credentials -----------

AWS_ACCESS_KEY_ID = 'Your AWS Access Key ID'
AWS_SECRET_ACCESS_KEY = 'Your AWS Secret Access Key'
AWS_ASSOCIATE_TAG = 'Your AWS Associate Tag'
AWS_CREDENTIALS = [AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_ASSOCIATE_TAG]        

# This file will hold all of our data
csvFile = 'priceHistory.csv'

# Before you start monitoring a product, add it to the data file
# For each product you add, you're also giving directions for a target price

# Xbox Wireless Controller
# Alert when current price drops at least 50%
addProduct('B01GW3H3U8', csvFile, -50, 'percentChange', AWS_CREDENTIALS)  

# Echo Dot
# Alert when current price drops at least 25%
addProduct('B01DFKC2SO', csvFile, -25, 'percentChange', AWS_CREDENTIALS) 

# Halo 5
# Alert when current price drops to at least $19.99
addProduct('B00DB9JV5W', csvFile, 19.99, 'desiredPrice', AWS_CREDENTIALS)

# You can also append new products at a later time to the same data file

priceHistory.csv

B01GW3H3U8|24.755
B01DFKC2SO|37.4925
B00DB9JV5W|19.99

Daily Monitoring of Prices

from AmazonAlert import addProduct, dailyScan

# ----- Gmail Credentials -----------

EMAIL_SELF = '[email protected]'
EMAIL_PASSWORD = 'yourpassword'    
EMAIL_FROM = EMAIL_SELF     
EMAIL_TO = EMAIL_SELF
EMAIL_CREDENTIALS = [EMAIL_SELF, EMAIL_PASSWORD, EMAIL_FROM, EMAIL_TO]
 
# ----- Amazon Credentials -----------

AWS_ACCESS_KEY_ID = 'Your AWS Access Key ID'
AWS_SECRET_ACCESS_KEY = 'Your AWS Secret Access Key'
AWS_ASSOCIATE_TAG = 'Your AWS Associate Tag'
AWS_CREDENTIALS = [AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_ASSOCIATE_TAG]        

# You should run this file on a dedicated server once or multiple times a day
# Personally, I run it daily at pythonanywhere.com
# Make sure all products have been properly initalized in the csvFile
# Otherwise they'll be skipped
# If any products fall below their target, you'll receieve an email!

def main():
    csvFile = 'priceHistory.csv'
    products = ['B01GW3H3U8', 'B01DFKC2SO', 'B00DB9JV5W']
    dailyScan(products, csvFile, AWS_CREDENTIALS, EMAIL_CREDENTIALS) 

if __name__ == '__main__':
    main()

Updated priceHistory.csv

B01GW3H3U8|24.755,2016-12-15|49.0
B01DFKC2SO|37.4925,2016-12-15|49.99
B00DB9JV5W|19.99,2016-12-15|24.78

Email Layout

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.