LoginSignup
10
11

More than 5 years have passed since last update.

Amazon Product Advertising APIで返却されたItemのXML構造

Last updated at Posted at 2015-11-21

Amazon Product Advertising APIで取得したXMLの構造がよくわからなかったので備忘録として残しておく。

構造は以下。

<Item>
  <ASIN>B0166CP8X4</ASIN>
  <DetailPageURL>http://www.amazon.co.jp/%E3%82%B9%E3%83%9E%E3%83%BC%E3%83%88%E3%83%95%E3%82%A9%E3%83%B3%E3%82%B2%E3%83%BC%E3%83%A0%E3%80%8C%E3%83%A9%E3%83%96%E3%83%A9%E3%82%A4%E3%83%96-%E3%82%B9%E3%82%AF%E3%83%BC%E3%83%AB%E3%82%A2%E3%82%A4%E3%83%89%E3%83%AB%E3%83%95%E3%82%A7%E3%82%B9%E3%83%86%E3%82%A3%E3%83%90%E3%83%AB%E3%80%8D%E3%82%B3%E3%83%A9%E3%83%9C%E3%82%B7%E3%83%B3%E3%82%B0%E3%83%AB%E3%80%8C%E3%82%BF%E3%82%A4%E3%83%88%E3%83%AB%E6%9C%AA%E5%AE%9A%E3%80%8D-%E3%83%87%E3%82%B8%E3%82%BF%E3%83%AB%E3%83%9F%E3%83%A5%E3%83%BC%E3%82%B8%E3%83%83%E3%82%AF%E3%82%AD%E3%83%A3%E3%83%B3%E3%83%9A%E3%83%BC%E3%83%B3%E5%AF%BE%E8%B1%A1%E5%95%86%E5%93%81-200%E5%86%86%E3%82%AF%E3%83%BC%E3%83%9D%E3%83%B3-Printemps/dp/B0166CP8X4%3FSubscriptionId%3DAKIAIEYD7HNIWEQWVPPA%26tag%3D56563145-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3DB0166CP8X4</DetailPageURL>
  <ItemLinks>
    <ItemLink>
      <Description>Add To Wishlist</Description>
      <URL>http://www.amazon.co.jp/gp/registry/wishlist/add-item.html%3Fasin.0%3DB0166CP8X4%26SubscriptionId%3DAKIAIEYD7HNIWEQWVPPA%26tag%3D56563145-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D5143%26creativeASIN%3DB0166CP8X4</URL>
    </ItemLink>
    <ItemLink>
      <Description>Tell A Friend</Description>
      <URL>http://www.amazon.co.jp/gp/pdp/taf/B0166CP8X4%3FSubscriptionId%3DAKIAIEYD7HNIWEQWVPPA%26tag%3D56563145-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D5143%26creativeASIN%3DB0166CP8X4</URL>
    </ItemLink>
    <ItemLink>
      <Description>All Customer Reviews</Description>
      <URL>http://www.amazon.co.jp/review/product/B0166CP8X4%3FSubscriptionId%3DAKIAIEYD7HNIWEQWVPPA%26tag%3D56563145-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D5143%26creativeASIN%3DB0166CP8X4</URL>
    </ItemLink>
    <ItemLink>
      <Description>All Offers</Description>
      <URL>http://www.amazon.co.jp/gp/offer-listing/B0166CP8X4%3FSubscriptionId%3DAKIAIEYD7HNIWEQWVPPA%26tag%3D56563145-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D5143%26creativeASIN%3DB0166CP8X4</URL>
    </ItemLink>
  </ItemLinks>
  <SalesRank>798</SalesRank>
  <SmallImage>
    <URL>http://ecx.images-amazon.com/images/I/612Q9CDddOL._SL75_.jpg</URL>
    <Height Units="pixels">74</Height>
    <Width Units="pixels">75</Width>
  </SmallImage>
  <MediumImage>
    <URL>http://ecx.images-amazon.com/images/I/612Q9CDddOL._SL160_.jpg</URL>
    <Height Units="pixels">158</Height>
    <Width Units="pixels">160</Width>
  </MediumImage>
  <LargeImage>
    <URL>http://ecx.images-amazon.com/images/I/612Q9CDddOL.jpg</URL>
    <Height Units="pixels">493</Height>
    <Width Units="pixels">500</Width>
  </LargeImage>
  <ImageSets>
    <ImageSet Category="primary">
      <SwatchImage>
        <URL>http://ecx.images-amazon.com/images/I/612Q9CDddOL._SL30_.jpg</URL>
        <Height Units="pixels">30</Height>
        <Width Units="pixels">30</Width>
      </SwatchImage>
      <SmallImage>
        <URL>http://ecx.images-amazon.com/images/I/612Q9CDddOL._SL75_.jpg</URL>
        <Height Units="pixels">74</Height>
        <Width Units="pixels">75</Width>
      </SmallImage>
      <ThumbnailImage>
        <URL>http://ecx.images-amazon.com/images/I/612Q9CDddOL._SL75_.jpg</URL>
        <Height Units="pixels">74</Height>
        <Width Units="pixels">75</Width>
      </ThumbnailImage>
      <TinyImage>
        <URL>http://ecx.images-amazon.com/images/I/612Q9CDddOL._SL110_.jpg</URL>
        <Height Units="pixels">108</Height>
        <Width Units="pixels">110</Width>
      </TinyImage>
      <MediumImage>
        <URL>http://ecx.images-amazon.com/images/I/612Q9CDddOL._SL160_.jpg</URL>
        <Height Units="pixels">158</Height>
        <Width Units="pixels">160</Width>
      </MediumImage>
      <LargeImage>
        <URL>http://ecx.images-amazon.com/images/I/612Q9CDddOL.jpg</URL>
        <Height Units="pixels">493</Height>
        <Width Units="pixels">500</Width>
      </LargeImage>
    </ImageSet>
  </ImageSets>
  <ItemAttributes>
    <Artist>Printemps</Artist>
    <Binding>CD</Binding>
    <Format>Single</Format>
    <Format>Maxi</Format>
    <ItemDimensions>
      <Height Units="hundredths-inches">39</Height>
      <Length Units="hundredths-inches">488</Length>
      <Weight Units="hundredths-pounds">110</Weight>
      <Width Units="hundredths-inches">551</Width>
    </ItemDimensions>
    <Label>ランティス</Label>
    <ListPrice>
      <Amount>1296</Amount>
      <CurrencyCode>JPY</CurrencyCode>
      <FormattedPrice>¥ 1,296</FormattedPrice>
    </ListPrice>
    <Manufacturer>ランティス</Manufacturer>
    <NumberOfDiscs>1</NumberOfDiscs>
    <NumberOfItems>1</NumberOfItems>
    <PackageDimensions>
      <Height Units="hundredths-inches">39</Height>
      <Length Units="hundredths-inches">551</Length>
      <Weight Units="hundredths-pounds">110</Weight>
      <Width Units="hundredths-inches">488</Width>
    </PackageDimensions>
    <ProductGroup>Music</ProductGroup>
    <ProductTypeName>ABIS_MUSIC</ProductTypeName>
    <Publisher>ランティス</Publisher>
    <ReleaseDate>2015-11-25</ReleaseDate>
    <Studio>ランティス</Studio>
    <Title>スマートフォンゲーム「ラブライブ!スクールアイドルフェスティバル」コラボシングル「タイトル未定」 (デジタルミュージックキャンペ ーン対象商品: 200円クーポン)</Title>
  </ItemAttributes>
  <OfferSummary>
    <LowestNewPrice>
      <Amount>1296</Amount>
      <CurrencyCode>JPY</CurrencyCode>
      <FormattedPrice>¥ 1,296</FormattedPrice>
    </LowestNewPrice>
    <TotalNew>1</TotalNew>
    <TotalUsed>0</TotalUsed>
    <TotalCollectible>0</TotalCollectible>
    <TotalRefurbished>0</TotalRefurbished>
  </OfferSummary>
</Item>

取得したときのresoinse_groupは"Medium"。

こんな感じで取得。

res3 = Amazon::Ecs.item_search( word, {:search_index => category, :response_group => 'Medium', :country => 'jp'})

取得したい内容はgetメソッドで取ってこれる。

puts j.get('ASIN') # ASINを取得
puts j.get('ItemAttributes/Title')

結果はこれ。

B0166CP8X4
スマートフォンゲーム「ラブライブ!スクールアイドルフェスティバル」コラボシングル「タイトル未定」 (デジタルミュージックキャンペーン対象商品: 200円クーポン)

get_elementで取得するとタグがついてくる。

puts j.get_element("Title")

結果はこれ。

<Title>スマートフォンゲーム「ラブライブ!スクールアイドルフェスティバル」コラボシングル「タイトル未定」 (デジタルミュージックキャンペーン 対象商品: 200円クーポン)</Title>

なんでラブライブ!なのかは・・・・察してください。備忘録でした。

10
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
11