【Python】JANコードからASINを取得する方法です。
PythonでAmazonのAPIを取得するため、「Amazon Simple Product API」ライブラリを使います。
サンプルコードは以下のとおりです。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from amazon.api import AmazonAPI | |
from amazon.api import LookupException, AsinNotFound | |
import sys | |
if __name__ == "__main__": | |
amazon = AmazonAPI( | |
"ACCESS_KEY", | |
"SECRET_KEY", | |
"ASSOC_TAG", | |
region="JP") | |
try: | |
product = amazon.lookup(ItemId="4971633002005", IdType="EAN", SearchIndex="All") | |
except LookupException: | |
sys.exit("Lookup Exception") | |
except AsinNotFound: | |
sys.exit("Asin Not Found") | |
except Exception, e: | |
sys.exit(e) | |
print product.asin |
ありがとうあずみちん