def list_maching_product(amazon_key, file_code): """TODO: Docstring for function. Description The ListMatchingProducts operation returns a list of products and their attributes, ordered by relevancy, based on a search query that you specify. Your search query can be a phrase that describes the product or it can be a product identifier such as a GCID, UPC, EAN, ISBN, or JAN. If you have the ASIN associated with your product, use the GetMatchingProduct operation. Note that the product identifier cannot be a SellerSKU. If your query does not return any matching products, the query will be broadened using spelling correction or the removal of keywords to find matches. This operation returns a maximum of ten products and does not return non-buyable products. 720 requests/s, 1 code :returns: TODO """ product_api = mws.Products(access_key, secret_key, seller_id, region='JP') asin_code_array = [] for get_asin_code in product_code: product = product_api.list_matching_products(marketplace_jp, get_asin_code).parsed try: asin_code = product.get('Products').get('Product')[0].get( 'Identifiers').get('MarketplaceASIN').get('ASIN').value except Exception: asin_code = "" asin_code_array.append(asin_code) return asin_code_array
def get_product_api(): access_key = 'AKIAJHPQJIW6QR5LWITQ' seller_id = 'A1Q8GZYLKNKOGP' secret_key = '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' marketplace_usa = 'ATVPDKIKX0DER' products_api = mws.Products(access_key, secret_key, seller_id, region='US') return products_api, marketplace_usa
def get_items(seller_id, auth_token, items): products_api = mws.Products( access_key=MWS_ACCESS_KEY, # INFO NOSSA (24U/Idea Shop) secret_key=MWS_SECRET_KEY, # INFO NOSSA (24U/Idea Shop) account_id=seller_id, # INFO LOJA (Seller ID) auth_token=auth_token) # INFO LOJA products = products_api.get_matching_product_for_id( 'ATVPDKIKX0DER', 'UPC', items) return products
def get_amazon_product_api(self): """ Create an instance of product api :return: Product API instance """ return mws.Products( access_key=self.amazon_access_key, secret_key=self.amazon_secret_key, account_id=self.amazon_merchant_id, )
def check_key(value, product_asin): """TODO: Docstring for check_key. :arg1: value key check ok :arg2: value sample asin :returns: TODO """ product_api = mws.Products(value['access_key'], value['secret_key'], value['seller_id'], region='JP') try: product_api.get_lowest_offer_listings_for_asin( marketplaceid=value['marketplace_jp'], asins=product_asin).parsed return product_api except Exception as e: error = e.args[0] xml_er = et.fromstring(error) for elem in xml_er.iter(): if elem.tag[-7:] == "Message": print('invalid amazon key: %s' % elem.text) return False
import os import configparser, time from myutil import myutil from mws import mws root_path = os.path.abspath('..') root_path = root_path.replace('\\', '/') config_path = myutil.get_path(root_path, ['app', 'config']) + 'config.ini' config = configparser.ConfigParser() config.read(config_path) access_key = config.get('mws', 'mws_access_key') secret_key = config.get('mws', 'mws_secret_key') account_id = config.get('mws', 'seller_id') market_place_id = config.get('mws', 'market_place_id') region = config.get('mws', 'region').upper() print(access_key, secret_key) product_client = mws.Products(access_key, secret_key, account_id, region) asins = [ 'B00Z8F00L6', 'B010EVS2BS', 'B009O0HZCI', 'B00FDVMSCE', 'B00MCA5UW4', 'B00YZLRJJU', 'B00FF0ND9U', 'B00C7GA8SE', 'B00SB2G9OK', 'B010EX3BVM', 'B011W95MY6', 'B00FG14BLC', 'B00Z8EXTCE', 'B00E6T3O18', 'B00N4JEHPS', 'B00ZVP8UW4', 'B00ZM398SK', 'B00YTJ1GLA', 'B00IJ0DITI', 'B00YZMNTXE' ] while True: try: res = product_client.get_lowest_offer_listings_for_asin( market_place_id, asins, 'Any') break except: pass time.sleep(10) print(res.parsed)
import json from lxml import etree as et import pandas as pd from time import sleep access_key = 'AKIAJUGV2KOGAEPQW3AQ' seller_id = 'AAMB7X48HI2IU' secret_key = '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' marketplace_jp = 'A1VC38T7YXB528' product_code = [ 'SH90/51', '4562154690019', '4902370502602', 'shaver', '4797398485' ] #get_asin_code = 'SH90/51' product_api = mws.Products(access_key, secret_key, seller_id, region='JP') asin_code_array = [] for get_asin_code in product_code: product = product_api.list_matching_products(marketplace_jp, get_asin_code).parsed try: asin_code = product.get('Products').get('Product')[0].get( 'Identifiers').get('MarketplaceASIN').get('ASIN').value except Exception: asin_code = "" asin_code_array.append(asin_code) #product = product_api.list_matching_products(marketplace_jp, get_asin_code).parsed #asin_code = product.get('Products').get('Product')[0].get('Identifiers').get('MarketplaceASIN').get('ASIN').value print(asin_code_array)
def get_buy_box_data(asin): attempts = 0 try: time.sleep(0.5) rand = randint(0, 3) merchant_id = sids[rand] auth_token = tokens[rand] x = mws.Products(access_key=access_key, secret_key=secret_key, account_id=merchant_id, auth_token=auth_token) report = x.get_lowest_priced_offers_for_asin( marketplaceid=marketplaceid, asin=asin, condition="New") response_data = report.original soup = BeautifulSoup(response_data, "lxml") total_offers = soup.find('totaloffercount').text if soup.find( 'totaloffercount') != None else '0' total_fba = soup.find( 'offercount', fulfillmentchannel="Amazon").text if soup.find( 'offercount', fulfillmentchannel="Amazon") != None else '0' feedback_count = 0 feedback_rating = 0 amz_on = 0 if soup.find('offer') == None: amz_on = 0 feedback_count = '0' feedback_rating = '0' else: for x in soup.findAll('offer'): temp_rating = x.find( 'sellerpositivefeedbackrating').text if x.find( 'sellerpositivefeedbackrating') != None else '0' temp_count = x.find('feedbackcount').text if x.find( 'feedbackcount') != None else '0' if x.find('isbuyboxwinner') == None: feedback_rating = 'N/A' feedback_count = 'N/A' elif x.find('isbuyboxwinner').text == 'true': feedback_rating = x.find( 'sellerpositivefeedbackrating').text if x.find( 'sellerpositivefeedbackrating') != None else '0' feedback_count = x.find('feedbackcount').text if x.find( 'feedbackcount') != None else '0' if temp_rating == '91.0' and temp_count == '387': amz_on = 1 feedback_rating = 'AMZ' feedback_count = 'AMZ' amz_on = 'Y' if amz_on == 1 else 'N' return (feedback_count, feedback_rating, total_offers, total_fba, amz_on) c.writerow([ asin, feedback_count, feedback_rating, total_offers, total_fba, amz_on ]) except urllib.error.HTTPError: attempts += 1 print('http fail: ' + str(attempts)) time.sleep(attempts * 3) except KeyboardInterrupt: exit() except Exception as exception: attempts += 1 print("Error: " + str(exception).partition(":")[0] + " - " + asin + " errored") if attempts == 2: pass
@app.route('/logout') def logout(): logout_user() return redirect(url_for('login')) @app.route('/') @app.route('/search') @login_required def post(): return render_template('search.html') products_api = mws.Products(k.access_key, k.secret_key, k.seller_id, region='US') @app.route("/", methods=['POST']) @app.route('/search', methods=['POST']) @login_required def search(): start = time.time() query = request.form['text'] products = products_api.list_matching_products( marketplaceid=k.marketplace_usa, query=query) productsxml = products.original xml = mws.remove_namespace(productsxml) soup1 = BeautifulSoup(xml, 'lxml') a = soup1.asin.string
from mws import mws abc = mws.MWS(access_key='AKIAIMJD6TQYTB5IUEMQ', secret_key='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', account_id='A10KER2CNUDHJL', auth_token='amzn.mws.5eacda7c-15c0-33c7-5c81-5fcb167d8949') abc.enumerate_param_obj('FeesEstimateRequestList.FeesEstimateRequest.', [{'MarketplaceId': 'ATVPDKIKX0DER', 'IdType': 'ASIN', 'IdValue': 'B002KT3XQM',\ 'IsAmazonFulfilled': True, 'Identifier': 'randomstring',\ 'PriceToEstimateFees.ListingPrice.CurrencyCode': 'USD',\ 'PriceToEstimateFees.ListingPrice.Amount': '30.00',\ 'PriceToEstimateFees.Shipping.CurrencyCode': 'USD',\ 'PriceToEstimateFees.Shipping.Amount': '3.99',\ 'PriceToEstimateFees.Points.PointsNumber': '0'},]) from mws import mws abc = mws.Products(access_key='AKIAIMJD6TQYTB5IUEMQ', secret_key='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', account_id='A10KER2CNUDHJL', auth_token='amzn.mws.5eacda7c-15c0-33c7-5c81-5fcb167d8949') a = abc.get_my_fees_estimate([{'MarketplaceId': 'ATVPDKIKX0DER', 'IdType': 'ASIN', 'IdValue': 'B002KT3XQM',\ 'IsAmazonFulfilled': 'true', 'Identifier': 'randomstring',\ 'PriceToEstimateFees.ListingPrice.CurrencyCode': 'USD',\ 'PriceToEstimateFees.ListingPrice.Amount': '30.00',\ 'PriceToEstimateFees.Shipping.CurrencyCode': 'USD',\ 'PriceToEstimateFees.Shipping.Amount': '3.99',\ 'PriceToEstimateFees.Points.PointsNumber': '0',},]) a.parsed.get('FeesEstimateResultList', {}).get('FeesEstimateResult', {}).get('FeesEstimate', {}).get('TotalFeesEstimate', {}).get('Amount', {}).get('value')
from amazon.api import AmazonAPI, AmazonProduct from mws import mws # Amazon Product Advertising API paapi = AmazonAPI(os.environ['AMAZON_ACCESS_KEY'], os.environ['AMAZON_SECRET_KEY'], os.environ['AMAZON_ASSOC_TAG']) mws_marketplace = os.environ['MWS_MARKETPLACE_ID'] mws_credentials = { 'access_key': os.environ['MWS_AWS_ACCESS_KEY_ID'], 'seller_id': os.environ['MWS_SELLER_ID'], 'secret_key': os.environ['MWS_SECRET_KEY'] } product_mws = mws.Products(access_key=mws_credentials['access_key'], account_id=mws_credentials['seller_id'], secret_key=mws_credentials['secret_key']) def product_lookup(search_by, user_input): """Handle requests for Amazon's Product Advertising API (PAAPI) product lookup. :param str search_by: earch by Criteria UPC or ASIN. :param str user_input: upc(s)/asin(s). """ if search_by == 'UPC': products = paapi.lookup(ItemId=user_input, IdType=search_by, SearchIndex='LawnAndGarden') elif search_by == 'ASIN':