Python code to have information of ASIN Numbers

80 Views Asked by At

I’m trying to request some information of ASIN numbers inside Amazon. I’m trying to use similar code like this:

import boto3
import json

amazon = boto3.client(
    'apapi',
    aws_access_key_id='',
    aws_secret_access_key='',
    region_name='us'
)

response = amazon.lookup(
    ItemId='B07VGRJDFY',
    ResponseGroup='ItemAttributes,Images,Offers',
    #AssociateTag='YOUR_ASSOCIATE_TAG',
    Condition='All',
    IdType='ASIN'
)

data = json.loads(response['Items'][0]['Item'].to_json())

title = data['ItemAttributes']['Title']
brand = data['ItemAttributes']['Brand']
image_url = data['LargeImage']['URL']
price = data['OfferSummary']['LowestNewPrice']['FormattedPrice']

product_data = {
    'title': title,
    'brand': brand,
    'image_url': image_url,
    'price': price
}

with open('product_data.json', 'w') as f:
    json.dump(product_data, f)

I don;t know how to make it work. From the resources group later I will request other elements but for now with test purposes that ones.

How can be modified the code to work?

Of course I have my secret keys created in AWS and they are active.

Thank you

0

There are 0 best solutions below