如何使用亚马逊的产品 API 获取新的可用书籍?

发布于 2024-10-30 01:26:33 字数 1048 浏览 1 评论 0原文

我正在尝试使用亚马逊产品 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ぽ尐不点ル 2024-11-06 01:26:33

抱歉,我没有发表评论的权限。不确定这是问题所在,但我认为仅获取可用产品的 ItemSearch 参数是“可用性”而不是“可用”。您还需要根据文档 (http://docs.amazonwebservices.com/AWSECommerceService/2010-11-01/DG/ItemSearch.html) 将此参数与商家 ID 和条件结合使用。您能否尝试更改:

is = ItemSearch.new( 'Books', {'Keywords' => 'Programming',
                              'Sort' => 'daterank',
                              'Available' => 'Available' })

上面给出

is = ItemSearch.new( 'Books', { 'Keywords' => 'Programming',
                              'Sort' => 'daterank',
                              'Availability' => 'Available',
                              'MerchantId' => 'ATVPDKIKX0DER',
                              'Condition' => 'All'})

的 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:

is = ItemSearch.new( 'Books', {'Keywords' => 'Programming',
                              'Sort' => 'daterank',
                              'Available' => 'Available' })

with

is = ItemSearch.new( 'Books', { 'Keywords' => 'Programming',
                              'Sort' => 'daterank',
                              'Availability' => 'Available',
                              'MerchantId' => 'ATVPDKIKX0DER',
                              'Condition' => 'All'})

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文