I've tried several xml parsing libraries and several Amazon libraries and have decided that the current combination of BeautifulSoup and bottlenose are what I enjoy working with the most. I've been able to bang out tools for myself using this combo very quickly and have actually had fun building each one of them for a change.
import bottlenose from BeautifulSoup import BeautifulSoup # Replace these values with your correct info AWS_KEY = 'key_goes_here' SECRET_KEY = 'secret_goes_here' ASSOCIATE_ID = 'your_associate_id_goes_here' # Create a bottlenose object and initialize with our credentials amazon = bottlenose.Amazon(AWS_KEY, SECRET_KEY) # Query Amazon's Product API to perform an item lookup via the ASIN, returns the large response # group containing a ton of info, note that we must send the associate id now response = amazon.ItemLookup(ItemId="B0018AFK38", ResponseGroup="Large", AssociateTag=ASSOCIATE_ID) # Create a BS object from the XML response soup = BeautifulSoup(response) # A sample of the data that can be retrieved print soup.find('itemid').string print soup.find('formattedprice').string print soup.find('detailpageurl').string print soup.find('sku').string print soup.find('content').string print soup.find('title').string print soup.find('department').string print soup.find('smallimage').url.string print soup.find('mediumimage').url.string print soup.find('largeimage').url.string
If what you are looking for is a simple, object oriented access to Amazon products (lookup and search), try python-amazon-simple-product-api:
ReplyDeletehttp://github.com/yoavaviram/python-amazon-simple-product-api
Its based on bottlenose and its the new kid on the block!
Thanks Yoav! I just watched your library on Github and really like how simple you've made the interface.
ReplyDelete