Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from amazon.api import AmazonAPI
- import MySQLdb
- import re
- from pprint import pprint
- from mws import mws
- from datetime import datetime, timedelta
- import time
- import timeit
- import dateutil.parser as parser
- # db.close()
- db = MySQLdb.connect(host="localhost", # your host, usually localhost
- user="root", # your username
- passwd="pass", # your password
- db="db_name") # name of the data base
- def lowest_price_for_beauty():
- amazon = AmazonAPI(creds)
- products = amazon.search(SearchIndex='Beauty',
- ResponseGroup='ItemAttributes,OfferFull,OfferListings,Offers,SalesRank,OfferSummary',
- Sort='salesrank', BrowseNode='3777891')
- cur = db.cursor()
- for p in products:
- title = p.title.replace("'", "")
- price = re.sub("[^0-9^.]", "", str(p.list_price))
- price = float(price)
- rank = int(0 if p.sales_rank is None else p.sales_rank)
- add = "INSERT INTO products(title, asin, upc, price, sales_rank) VALUES('%s', '%s', '%s', %s, %s)" % (title, p.asin, p.upc, price, rank)
- cur.execute(add)
- db.commit()
- print("Commited")
- cur.close()
- from flask import Flask
- from flask import request
- from main import main
- app = Flask(__name__)
- @app.route('/')
- def home():
- return"Hello world"
- File "/home/brennan/_repos/amazonpython/main/main.py", line 1, in <module>
- from amazon.api import AmazonAPI
- ImportError: No module named amazon.api
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement