- 追加された行はこの色です。
- 削除された行はこの色です。
#author("2018-07-31T15:40:24+09:00","default:wikiwriter","wikiwriter")
&tag(amazon-ecs);
*目次 [#q5adce04]
#contents
*関連ページ [#p01a707f]
-[[jugend/amazon-ecs: Ruby Amazon Product Advertising API:https://github.com/jugend/amazon-ecs]]
*参考情報 [#l035b415]
*概要 [#yc0a78fe]
-Amazon Product Advertising APIを使用するためのRubyライブラリ。
*基本 [#y40a274b]
-返却されてくるXMLの構造。[[Amazon Product Advertising APIで返却されたItemのXML構造:https://qiita.com/yatta47/items/8df1944dd868f8232f3f]]
-ASINはItemの直接の子どもだが、TitleはItemAttributesの子どもとなっている。
-Amazon::ECS.item_searchはAmazon::Elementの配列が返ってくる。
-item.get_element("Title")ではAmazon::Elementが返ってくる。
-item.get("Title")でテキスト表現。
-item.elemで Nokogiri::XML::Element が取得できる。
*検索結果のItemのXML [#m69ecca3]
-返却されてくるXMLの構造。[[Amazon Product Advertising APIで返却されたItemのXML構造:https://qiita.com/yatta47/items/8df1944dd868f8232f3f]]
-実物(URLは"?"以降省略)。
#pre{{
<Item>
<ASIN>4774193976</ASIN>
<DetailPageURL>https://www.amazon.co.jp/%E3%83%97%E3%83%AD%E3%82%92%E7%9B%AE%E6%8C%87%E3%81%99%E4%BA%BA%E3%81%AE%E3%81%9F%E3%82%81%E3%81%AERuby%E5%85%A5%E9%96%80-%E8%A8%80%E8%AA%9E%E4%BB%95%E6%A7%98%E3%81%8B%E3%82%89%E3%83%86%E3%82%B9%E3%83%88%E9%A7%86%E5%8B%95%E9%96%8B%E7%99%BA%E3%83%BB%E3%83%87%E3%83%90%E3%83%83%E3%82%B0%E6%8A%80%E6%B3%95%E3%81%BE%E3%81%A7-Software-Design-plus%E3%82%B7%E3%83%AA%E3%83%BC%E3%82%BA/dp/4774193976</DetailPageURL>
<ItemLinks>
<ItemLink>
<Description>Add To Wishlist</Description>
<URL>https://www.amazon.co.jp/gp/registry/wishlist/add-item.html</URL>
</ItemLink>
<ItemLink>
<Description>Tell A Friend</Description>
<URL>https://www.amazon.co.jp/gp/pdp/taf/4774193976</URL>
</ItemLink>
<ItemLink>
<Description>All Customer Reviews</Description>
<URL>https://www.amazon.co.jp/review/product/4774193976</URL>
</ItemLink>
<ItemLink>
<Description>All Offers</Description>
<URL>https://www.amazon.co.jp/gp/offer-listing/4774193976</URL>
</ItemLink>
</ItemLinks>
<SalesRank>4003</SalesRank>
<SmallImage>
<URL>https://images-fe.ssl-images-amazon.com/images/I/51nY-YLt2ZL._SL75_.jpg</URL>
<Height Units="pixels">75</Height>
<Width Units="pixels">60</Width>
</SmallImage>
<MediumImage>
<URL>https://images-fe.ssl-images-amazon.com/images/I/51nY-YLt2ZL._SL160_.jpg</URL>
<Height Units="pixels">160</Height>
<Width Units="pixels">127</Width>
</MediumImage>
<LargeImage>
<URL>https://images-fe.ssl-images-amazon.com/images/I/51nY-YLt2ZL.jpg</URL>
<Height Units="pixels">500</Height>
<Width Units="pixels">397</Width>
</LargeImage>
<ImageSets>
<ImageSet Category="primary">
<SwatchImage>
<URL>https://images-fe.ssl-images-amazon.com/images/I/51nY-YLt2ZL._SL30_.jpg</URL>
<Height Units="pixels">30</Height>
<Width Units="pixels">24</Width>
</SwatchImage>
<SmallImage>
<URL>https://images-fe.ssl-images-amazon.com/images/I/51nY-YLt2ZL._SL75_.jpg</URL>
<Height Units="pixels">75</Height>
<Width Units="pixels">60</Width>
</SmallImage>
<ThumbnailImage>
<URL>https://images-fe.ssl-images-amazon.com/images/I/51nY-YLt2ZL._SL75_.jpg</URL>
<Height Units="pixels">75</Height>
<Width Units="pixels">60</Width>
</ThumbnailImage>
<TinyImage>
<URL>https://images-fe.ssl-images-amazon.com/images/I/51nY-YLt2ZL._SL110_.jpg</URL>
<Height Units="pixels">110</Height>
<Width Units="pixels">87</Width>
</TinyImage>
<MediumImage>
<URL>https://images-fe.ssl-images-amazon.com/images/I/51nY-YLt2ZL._SL160_.jpg</URL>
<Height Units="pixels">160</Height>
<Width Units="pixels">127</Width>
</MediumImage>
<LargeImage>
<URL>https://images-fe.ssl-images-amazon.com/images/I/51nY-YLt2ZL.jpg</URL>
<Height Units="pixels">500</Height>
<Width Units="pixels">397</Width>
</LargeImage>
</ImageSet>
</ImageSets>
<ItemAttributes>
<Author>伊藤 淳一</Author>
<Binding>大型本</Binding>
<EAN>9784774193977</EAN>
<EANList>
<EANListElement>9784774193977</EANListElement>
</EANList>
<IsAdultProduct>0</IsAdultProduct>
<ISBN>4774193976</ISBN>
<Label>技術評論社</Label>
<Languages>
<Language>
<Name>日本語</Name>
<Type>Published</Type>
</Language>
</Languages>
<Manufacturer>技術評論社</Manufacturer>
<NumberOfPages>472</NumberOfPages>
<PackageDimensions>
<Height Units="100分の1インチ">102</Height>
<Length Units="100分の1インチ">913</Length>
<Weight Units="100分の1ポンド">163</Weight>
<Width Units="100分の1インチ">717</Width>
</PackageDimensions>
<ProductGroup>Book</ProductGroup>
<ProductTypeName>ABIS_BOOK</ProductTypeName>
<PublicationDate>2017-11-25</PublicationDate>
<Publisher>技術評論社</Publisher>
<Studio>技術評論社</Studio>
<Title>プロを目指す人のためのRuby入門 言語仕様からテスト駆動開発・デバッグ技法まで (Software Design plusシリーズ)</Title>
</ItemAttributes>
<OfferSummary>
<LowestNewPrice>
<Amount>3218</Amount>
<CurrencyCode>JPY</CurrencyCode>
<FormattedPrice>¥ 3,218</FormattedPrice>
</LowestNewPrice>
<LowestUsedPrice>
<Amount>5364</Amount>
<CurrencyCode>JPY</CurrencyCode>
<FormattedPrice>¥ 5,364</FormattedPrice>
</LowestUsedPrice>
<TotalNew>5</TotalNew>
<TotalUsed>5</TotalUsed>
<TotalCollectible>0</TotalCollectible>
<TotalRefurbished>0</TotalRefurbished>
</OfferSummary>
</Item>
}}
*サンプル [#h8efa7c1]
**Rubyというキーワードを含む書籍を検索 [#q43d8192]
-以下のようになる。
#pre{{
require 'rubygems'
require "bundler/setup"
require 'amazon/ecs'
# デバッグ
Amazon::Ecs::debug = true
Amazon::Ecs.options = {
:associate_tag => "xxxxx",
:AWS_access_key_id => "yyyyy",
:AWS_secret_key => "zzzzz"
}
def search_books
# 本のなかでRubyというキーワードを含むものを検索。
res = Amazon::Ecs.item_search('ruby', {:search_index => 'Books', :response_group => 'Medium', :country => 'jp'})
res.items.each do |item|
# タイトルを取得&表示
puts item.get_element("Title")
# 著者を取得&表示
puts item.get_element("Author")
end
end
}}