Skip to content

Instantly share code, notes, and snippets.

@nishidy
Last active June 18, 2017 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nishidy/5ea506b145c4e887003914e68d525b61 to your computer and use it in GitHub Desktop.
Save nishidy/5ea506b145c4e887003914e68d525b61 to your computer and use it in GitHub Desktop.
Amazon Product API
import os
import time
from amazon.api import AmazonAPI
AMAZON_ACCESS_KEY = os.environ['AWSAccessKeyId']
AMAZON_SECRET_KEY = os.environ['AWSSecretKey']
AMAZON_ASSOC_TAG = os.environ['AWSAssocId']
print(AMAZON_ACCESS_KEY[-5:])
print(AMAZON_SECRET_KEY[-5:])
print(AMAZON_ASSOC_TAG[-5:])
amazon = AmazonAPI(AMAZON_ACCESS_KEY, AMAZON_SECRET_KEY, AMAZON_ASSOC_TAG, region="JP")
time.sleep(1)
product = amazon.lookup(ItemId='B01NBV0SUW')
print(product.title)
print(product.price_and_currency)
print(product.ean)
print(product.large_image_url)
print(product.get_attribute('Publisher'))
print(product.get_attributes(['ItemDimensions.Width', 'ItemDimensions.Height']))
time.sleep(1)
products = amazon.search_n(10,Keywords='kindle',SearchIndex='All')
for i, product in enumerate(products):
print("#{0}: {1}".format(i,product.title))
time.sleep(1)
products = amazon.search_n(10,Keywords='adidas,shoes,25.0',SearchIndex='All')
for i, product in enumerate(products):
print("#{0}: {1} {2}".format(i,product.title[:75],product.price_and_currency))
@nishidy
Copy link
Author

nishidy commented May 21, 2017

$ python amazon_api_test.py 
xx6EQ
xxocm
xx-22
[パタゴニア] patagonia Atom Sling 48260 Big Sur Blue(BSRB)
(Decimal('7344'), 'JPY')
0889833708686
https://images-fe.ssl-images-amazon.com/images/I/4166tpceb2L.jpg
Patagonia
{'ItemDimensions.Width': '937', 'ItemDimensions.Height': '165'}
#0: Kindle Paperwhite 32GB、マンガモデル、Wi-Fi 、ブラック、キャンペーン情報つきモデル
#1: Kindle Paperwhite Wi-Fi、ブラック
#2: Kindle for PC (Windows) [ダウンロード]
#3: Kindle (Newモデル) Wi-Fi、ホワイト、キャンペーン情報つきモデル、電子書籍リーダー
#4: Fire HD 8 タブレット 16GB、ブラック
#5: Fire タブレット 8GB、ブラック
#6: Kindle for Mac [ダウンロード]
#7: Kindle Voyage Wi-Fi、キャンペーン情報つきモデル、電子書籍リーダー
#8: いぬやしき(9)【電子特典付き】 (イブニングコミックス)
#9: Fintie Kindle Paperwhite ケース 超薄 軽量 保護カバー オートスリープ機能付き (2016 NEW-Kindle Paperwhiteマンガモデル と 2012, 2013, 2015バージョン適応)(ネイビー)
#0: [アディダス] ランニングシューズ Galaxy 3 KDV76   (17春夏) BB4362グレー/グレー/コアレッド S17 25.0 (Decimal('4326'), 'JPY')
#1: [アディダス] ランニングシューズ Galaxy 3 W KDV77 BB4365コアブラック/ダークグレー/ランニングホワイト 25.0 (Decimal('3880'), 'JPY')
#2: [アディダス] ランニングシューズ Galaxy 2 4E KDL45 AQ2891ランニングホワイト/コアブラック/シルバーメット 25.0 (Decimal('4346'), 'JPY')
#3: [アディダス] ランニングシューズ adiZERO boston BOOST 2 KDI95 BB0537エナジー S17/カレッジネイビー/カレッジ (Decimal('9597'), 'JPY')
#4: [アディダス] サッカーシューズ エックス 16.4 TF KCD28 BB5683レッド/ランニングホワイト/コアブラック 25.0 (Decimal('5012'), 'JPY')
#5: [アディダス] トレッキングシューズ TERREX AX2R GTX IJP87 BB1987ナイトブラウン/コアブラック/ブラウン 25.0 (Decimal('9599'), 'JPY')
#6: [アディダス] ランニングシューズ adiZERO japan BOOST 3 W CCC03 BA7948イージーオレンジ S17/ランニングホワイ (Decimal('11551'), 'JPY')
#7: [アディダス] サッカーシューズ エックス 16.3 TF KCD22 BB5663レッド/ランニングホワイト/コアブラック 25.0 (Decimal('6011'), 'JPY')
#8: [アディダス] ランニングシューズ Galaxy 2 4E W KDL48 AQ2898クリアグラナイト/イーキューティーピンク S16/グラナイト  (Decimal('4377'), 'JPY')
#9: [アディダス] adidas ランニングシューズ Galaxy 3 W KDV77 AQ6557 スーパーパープルS16/スーパーパープルS16/サン (Decimal('4500'), 'JPY')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment