Skip to content

Instantly share code, notes, and snippets.

@ejschmitt
Created May 17, 2009 21:42
Show Gist options
  • Save ejschmitt/113172 to your computer and use it in GitHub Desktop.
Save ejschmitt/113172 to your computer and use it in GitHub Desktop.
require 'amazon/aws'
require 'amazon/aws/search'
include Amazon::AWS
include Amazon::AWS::Search
KEY_ID = ""
ASSOCIATES_ID = ""
def self.get_aws_ads(keywords)
is = ItemSearch.new( 'All', { 'Keywords' => keywords } )
rg = ResponseGroup.new( 'Large' )
req = Request.new(KEY_ID, ASSOCIATES_ID)
resp = req.search( is, rg )
items = resp.item_search_response[0].items[0].item
#puts items[0].properties
items.map do |i|
price = i.offers[0].offer[0].offer_listing[0].price[0].formatted_price.to_s rescue nil
{
:item => i.item_attributes.title.to_s,
:url => i.detail_page_url.to_s,
:price => price
}
end
rescue
puts "ERROR"
return []
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment