2011-11-09 58 views
3

當使用他們的API搜索亞馬遜時,是否有辦法將精裝書,平裝書,kindle和可預訂書籍分開?亞馬遜API和精裝與平裝

我正在使用Ruby和Amazon Product gem,並且一直在搜索他們的文檔以查找相關信息,並且尚未設法找到任何內容。

更新: 我遇到了一些起點,我正在努力。如here所述,似乎有一種通過RrelatedItems ResponseGroup獲取此信息的方法。 KindleStore層次結構似乎相關。

更新II:

綁定可能是我需要以某種方式看待和亞馬遜的API使用AlternativeVersion ResponseGroup類型的書籍前往AlternateVersions of an ASIN的方式領域。

回答

4

我將假設您知道如何正確設置Amazon Product Gem請求對象。從那裏,你可以做...

search = req.search('Ender\'s Game') 
search.each('Item') do |item| 
    asin = item["ASIN"] 
    title = item['ItemAttributes']['Title'] 
    hash = { 
    :response_group => ['ItemAttributes'] 
    } 
    items = req.find(asin, hash) 
    items.each('Item') do |ia| 
    puts "[#{asin}]: #{title} => [#{ia['ItemAttributes']['Binding']}]" 
    end 
end 

產生像

[0812550706]: Ender's Game (Ender, Book 1) => [Mass Market Paperback] 
[0765362430]: The Ender Quartet Box Set: Ender's Game, Speaker for the Dead, Xenocide, Children of the Mind => [Mass Market Paperback] 
[0812550757]: Speaker for the Dead (Ender, Book 2) => [Mass Market Paperback] 
[0765342405]: Ender's Shadow (Ender, Book 5) => [Paperback] 
[B003G4W49C]: Ender's Game => [Kindle Edition] 
[0785135820]: Ender's Game: Command School => [Hardcover] 
[0785135804]: Ender's Game: Battle School (Ender's Game Gn) => [Hardcover] 
[0765362449]: The Ender's Shadow Series Box Set: Ender's Shadow, Shadow of the Hegemon, Shadow Puppets, Shadow of the Giant => [Paperback] 
[0785136096]: Ender's Game: Formic Wars: Burning Earth => [Hardcover] 
[0812565959]: Shadow of the Hegemon (Ender, Book 6) => [Mass Market Paperback] 
輸出