1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

rubyのgem:amazon-ecsを利用したメモ

Last updated at Posted at 2016-08-01

いつも「Amazon」でショッピングしているので、値段が安い時に買いたいですね。
また、定期便も値段が変わることがあります、知らないうちに、値段が上がる時もありました。
そのため、手軽に使うアプリがあればいいなと思い、値段の変動情報を通知してくれるアプリを開発しました。
Amazon情報を取得するため、rubyのgem「amazon-ecs」を使ってみました。

使い方

yml設定

ecs.yml
AWS_access_key_id: "xxxxxxxxxxxxxxxxxxxx" # 必須
AWS_secret_key: "xxxxxxxxxxxxxxxxxxxx" # 必須
associate_tag: "xxxxxx-22" # 必須
response_group: "ItemAttributes, Images, SalesRank, OfferSummary" # レスポンスに含まれる情報量

初期設定

ecs_yml = YAML.load_file("#{Rails.root}/config/ecs.yml")
keys = [:AWS_access_key_id, :AWS_secret_key, :associate_tag, :response_group]
Amazon::Ecs.configure do |options|
  keys.each do |key|
    options[key] = ecs_yml[key.to_s] if ecs_yml[key.to_s].present?
  end
end

呼び出し

res = Amazon::Ecs.item_lookup(asin, :country => country) # 一件だけ検索する
title = item.get('ItemAttributes/Title') # 商品名
price = item.get('OfferSummary/LowestNewPrice/FormattedPrice') # 値段
image_url = item.get('MediumImage/URL') # 商品画像

実装済みアプリ

1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?