Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. from amazon.api import AmazonAPI
  2. import MySQLdb
  3. import re
  4. from pprint import pprint
  5. from mws import mws
  6. from datetime import datetime, timedelta
  7. import time
  8. import timeit
  9. import dateutil.parser as parser
  10.  
  11.  
  12. # db.close()
  13.  
  14.  
  15. db = MySQLdb.connect(host="localhost", # your host, usually localhost
  16. user="root", # your username
  17. passwd="pass", # your password
  18. db="db_name") # name of the data base
  19.  
  20.  
  21. def lowest_price_for_beauty():
  22.  
  23. amazon = AmazonAPI(creds)
  24.  
  25. products = amazon.search(SearchIndex='Beauty',
  26. ResponseGroup='ItemAttributes,OfferFull,OfferListings,Offers,SalesRank,OfferSummary',
  27. Sort='salesrank', BrowseNode='3777891')
  28.  
  29. cur = db.cursor()
  30. for p in products:
  31.  
  32.  
  33. title = p.title.replace("'", "")
  34. price = re.sub("[^0-9^.]", "", str(p.list_price))
  35. price = float(price)
  36. rank = int(0 if p.sales_rank is None else p.sales_rank)
  37. add = "INSERT INTO products(title, asin, upc, price, sales_rank) VALUES('%s', '%s', '%s', %s, %s)" % (title, p.asin, p.upc, price, rank)
  38. cur.execute(add)
  39.  
  40. db.commit()
  41. print("Commited")
  42. cur.close()
  43.  
  44. from flask import Flask
  45. from flask import request
  46. from main import main
  47.  
  48. app = Flask(__name__)
  49.  
  50.  
  51. @app.route('/')
  52. def home():
  53. return"Hello world"
  54.  
  55. File "/home/brennan/_repos/amazonpython/main/main.py", line 1, in <module>
  56. from amazon.api import AmazonAPI
  57. ImportError: No module named amazon.api
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement