Vacuum is a thin Ruby wrapper to various [Amazon Web Services (AWS) APIs] 3.
![vacuum] 4
gem install vacuumVacuum knows the [Amazon Product Advertising API] 5 inside out.
Set up a request:
req = Vacuum.new :product_advertising
req.configure do |config|
config.key = 'key'
config.secret = 'secret'
config.tag = 'tag'
endBuild and run a search:
req.build operation: 'ItemSearch',
search_index: 'Books',
keywords: 'Deleuze'
res = req.get
res.valid? or raise res.code
p res.bodyOr run the same search less verbosely:
res = req.search :books, 'Deleuze'
p res.bodyThe response wraps a [Nokogiri] 6 document:
res.xmlAnd lets you drop down to any node:
res.find('Item') do |item|
p item
endBrowse more examples [here] 7.
The wrapper to the [Amazon Marketplace Web Services API] 8 is a work-in-progress.
Set up a request to the Products API:
req = Vacuum.new(:mws_products) do |config|
config.locale = 'US'
config.key = 'key'
config.secret = 'secret'
config.marketplace = 'marketplace'
config.seller = 'seller'
endGet the lowest offers for a single ASIN:
req.build 'Action' => 'GetLowestOfferListingsForASIN',
'ASINList.ASIN.1' => '0231081596'
offers = req.get.find 'GetLowestOfferListingsForASINResult'I will at some point throw in some syntactic sugar for common operations.
Vacuum should work with all AWS libraries, including EC2, S3, IAM, SimpleDB, SQS, SNS, SES, and ELB. Most of these already have popular Ruby implementations. If you need to implement one using Vacuum, please fork and send a pull request when done.
You can use any of the alternative adapters [Faraday] 9 supports:
req.connection do |builder|
builder.adapter :em_synchrony
end![vacuums] 10
Workers queuing to crawl AWS.