如何使用亚马逊的产品 API 获取新的可用书籍?
我正在尝试使用亚马逊产品 api 来获取他们新的可用书籍的列表,但我在执行此操作时遇到了困难。我目前正在使用我发现的 ruby-aaws-0.8.1 gem 此处。
现在我已经设置了代码,可以使用关键字获取最新的书籍,并设置了日期排名,但目前 api 正在给我返回最新的书籍,但是有没有办法获得它,以便它可以给我最新的书籍可用的书?
这是我收到的第一个回复,但这本书目前不可用。 http://www.amazon.com/Artificial-Intelligence-Programming-techniques-Basic/ dp/B000YC4KT6
#!/usr/bin/ruby -w
require 'amazon/aws/search'
include Amazon::AWS
include Amazon::AWS::Search
is = ItemSearch.new( 'Books', { 'Keywords' => 'Programming',
'Sort' => 'daterank',
'Available' => 'Available' })
is.response_group = ResponseGroup.new( 'Small' )
req = Request.new()
req.locale = 'us'
resp = req.search( is, 1 )
items = resp.item_search_response[0].items[0].item
items.each { |item| puts item, '' }
puts items.count
I am trying to use amazons product api to get a list of their new available books and I am having trouble doing it. I am currently using the ruby-aaws-0.8.1 gem that I found here.
Right now I have set up code that gets me the newest book using a keyword and have set a date rank but currently the api is giving me back the newest book, but is there a way to have it so that it can give me the newest available book?
This is the first response I am getting back, but this book is currently not available. http://www.amazon.com/Artificial-Intelligence-Programming-techniques-Basic/dp/B000YC4KT6
#!/usr/bin/ruby -w
require 'amazon/aws/search'
include Amazon::AWS
include Amazon::AWS::Search
is = ItemSearch.new( 'Books', { 'Keywords' => 'Programming',
'Sort' => 'daterank',
'Available' => 'Available' })
is.response_group = ResponseGroup.new( 'Small' )
req = Request.new()
req.locale = 'us'
resp = req.search( is, 1 )
items = resp.item_search_response[0].items[0].item
items.each { |item| puts item, '' }
puts items.count
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
抱歉,我没有发表评论的权限。不确定这是问题所在,但我认为仅获取可用产品的 ItemSearch 参数是“可用性”而不是“可用”。您还需要根据文档 (http://docs.amazonwebservices.com/AWSECommerceService/2010-11-01/DG/ItemSearch.html) 将此参数与商家 ID 和条件结合使用。您能否尝试更改:
上面给出
的 MerchantId 是亚马逊的美国 MerchantId。如果您想查看亚马逊在其他国家/地区的库存,或者您想查看第三方(阅读非亚马逊)的库存,您将需要相应地更改此 MerchantId。
Sorry, I don't have privilege to comment. Not sure this is the issue, but I think the ItemSearch parameter to get only available products is "Availability" rather than "Available". You will also need to use this parameter in combination with a Merchant ID and Condition as per the doc (http://docs.amazonwebservices.com/AWSECommerceService/2010-11-01/DG/ItemSearch.html). Could you please try changing:
with
The MerchantId given above is Amazon's US MerchantId. You will need to change this MerchantId accordingly if you want to look at Amazon's inventory in other countries, or if you want to look at third party's (read non-Amazon) inventory.