{"id":148,"date":"2009-07-30T01:24:20","date_gmt":"2009-07-29T16:24:20","guid":{"rendered":"http:\/\/www.typea.info\/blog\/index.php\/2009\/07\/30\/amazon_product_advertising_api_python\/"},"modified":"2009-07-30T01:24:20","modified_gmt":"2009-07-29T16:24:20","slug":"amazon_product_advertising_api_python","status":"publish","type":"post","link":"https:\/\/www.typea.info\/blog\/index.php\/2009\/07\/30\/amazon_product_advertising_api_python\/","title":{"rendered":"Amazon Product Advertising API \u3092 Python \u304b\u3089\u4f7f\u3046"},"content":{"rendered":"<p>Amazon \u30a2\u30bd\u30b7\u30a8\u30a4\u30c8 Web \u30b5\u30fc\u30d3\u30b9\u306e\u540d\u79f0\u304c\u3001\u300cProduct Advertising API\u300d\u306b\u5909\u308f\u308a\u3001\u96fb\u5b50\u7f72\u540d\u3092 8\u670815\u65e5\u307e\u3067\u306b\u30ea\u30af\u30a8\u30b9\u30c8\u306b\u542b\u3081\u308b\u5fc5\u8981\u304c\u3042\u308b\u65e8\u306e\u30e1\u30fc\u30eb\u304c\u5148\u65e5\u5c4a\u3044\u305f\u3002<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/AmazonProductAdvertisingAPIPython_14AC8\/ama_py01.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" border=\"0\" alt=\"ama_py01\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/AmazonProductAdvertisingAPIPython_14AC8\/ama_py01_thumb.jpg\" width=\"336\" height=\"111\" \/><\/a> <\/p>\n<p>GAE\/Python \u4e0a\u306b\u3001Amazon \u60c5\u5831\u53d6\u5f97\u51e6\u7406\u3092\u7f6e\u304f\u3053\u3068\u3092\u5ff5\u982d\u306b\u3001\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u30b5\u30f3\u30d7\u30eb\u3092\u4f5c\u6210\u3057\u3066\u307f\u308b\u3002<\/p>\n<p>\u307e\u305a\u3001\u53c2\u7167\u3059\u3079\u304d\u30da\u30fc\u30b8\u3002<\/p>\n<ul>\n<li><a href=\"http:\/\/docs.amazonwebservices.com\/AWSECommerceService\/latest\/GSG\/\">Amazon Product Advertising API \u30b9\u30bf\u30fc\u30c8\u30ac\u30a4\u30c9<\/a> <\/li>\n<li><a href=\"https:\/\/affiliate.amazon.co.jp\/gp\/associates\/help\/t126\">Product Advertising API \u958b\u767a\u8005\u5411\u3051\u30ac\u30a4\u30c9 \u30ea\u30af\u30a8\u30b9\u30c8\u306e\u7f72\u540d\u8a8d\u8a3c\u306b\u3064\u3044\u3066\uff08\u53c2\u8003\u8a33\uff09<\/a> <\/li>\n<li><a href=\"http:\/\/docs.amazonwebservices.com\/AWSECommerceService\/latest\/DG\/index.html?CHAP_ApiReference.html\">API\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9<\/a> <\/li>\n<\/ul>\n<p>\u4ee5\u4e0b\u3001\u7c21\u5358\u306b Product Advertising API \u3092\u5229\u7528\u3059\u308b\u305f\u3081\u306e\u6982\u8981\u3002<\/p>\n<h3><strong>1.Amazon Web Services \u30a2\u30ab\u30a6\u30f3\u30c8\u306e\u53d6\u5f97<\/strong><\/h3>\n<ul>\n<li>Amazon Product Advertising API (\u9577\u3044\u30fb\u30fb\u30fb) \u3092\u5229\u7528\u3057\u3066\u3001Amazon\u306e\u60c5\u5831\u3092\u5229\u7528\u3059\u308b\u305f\u3081\u306b\u306f\u3001\u3059\u3079\u3066\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u306b\u3001\u306eAWS\u30a2\u30af\u30bb\u30b9\u8b58\u5225\u60c5\u5831\u3092\u542b\u3081\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002 <\/li>\n<li>\u30a2\u30af\u30bb\u30b9\u8b58\u5225\u60c5\u5831\u306f\u3001\u30a2\u30eb\u30d5\u30a1\u30d9\u30c3\u30c8\u3068\u6570\u5b57\u304b\u3089\u306a\u308a\u30ea\u30af\u30a8\u30b9\u30c8\u9001\u4fe1\u8005\u3092\u4e00\u610f\u306b\u8b58\u5225\u3059\u308b\u3002 <\/li>\n<li>AWS Access Key ID \u3068AWS Secret Access Key\u3068\u304c\u3042\u308a\u3001\u30a2\u30ab\u30a6\u30f3\u30c8\u306e\u53d6\u5f97\u306b\u3088\u308a\u3001\u53c2\u7167\u53ef\u80fd\u3068\u306a\u308b <\/li>\n<li>\u30a2\u30ab\u30a6\u30f3\u30c8\u306e\u53d6\u5f97\u306f<a title=\"http:\/\/aws.amazon.com\/\" href=\"http:\/\/aws.amazon.com\/\">http:\/\/aws.amazon.com\/<\/a>\u304b\u3089\u884c\u3044\u3001\u53d6\u5f97\u3059\u308b\u3068\u3001Your Account\u30e1\u30cb\u30e5\u30fc &#8211; Account Identifies \u304b\u3089\u53c2\u7167\u53ef\u80fd <\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/AmazonProductAdvertisingAPIPython_14AC8\/ama_py02.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" border=\"0\" alt=\"ama_py02\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/AmazonProductAdvertisingAPIPython_14AC8\/ama_py02_thumb.jpg\" width=\"244\" height=\"163\" \/><\/a> <\/p>\n<p><font color=\"#8080ff\">Your Account\u30e1\u30cb\u30e5\u30fc &#8211; Account Identifies \u304b\u3089\u30fb\u30fb\u30fb<\/font><\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/AmazonProductAdvertisingAPIPython_14AC8\/ama_py03.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" border=\"0\" alt=\"ama_py03\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/AmazonProductAdvertisingAPIPython_14AC8\/ama_py03_thumb.jpg\" width=\"244\" height=\"167\" \/><\/a> <\/p>\n<p><font color=\"#0080c0\">AWS Access Key ID \u3068AWS Secret Access Key\u3068\u53c2\u7167\u3067\u304d\u308b<\/font><\/p>\n<h3><strong>2.\u30a2\u30bd\u30b7\u30a8\u30a4\u30c8\u306b\u306a\u308b<\/strong><\/h3>\n<ul>\n<li>\u30a2\u30bd\u30b7\u30a8\u30a4\u30c8\u306f\u81ea\u5206\u306eWeb\u30b5\u30a4\u30c8\u304b\u3089Amazon\u306e\u30b5\u30a4\u30c8\u3092\u53c2\u7167\u3057\u8ca9\u58f2\u624b\u6570\u6599\u3092\u5f97\u308b <\/li>\n<li>\u30a2\u30bd\u30b7\u30a8\u30a4\u30c8\u3068\u306a\u308b\u306b\u306f\u3001Associate ID \u304c\u5fc5\u8981 <\/li>\n<li>Associate ID \u306f\u767b\u9332\u3057\u305f\u5730\u57df\u3067\u306e\u307f\u6709\u52b9 <\/li>\n<li>\u30a2\u30bd\u30b7\u30a8\u30a4\u30c8\u306e\u767b\u9332\u306f\u3001<a title=\"https:\/\/affiliate.amazon.co.jp\/\" href=\"https:\/\/affiliate.amazon.co.jp\/\">https:\/\/affiliate.amazon.co.jp\/<\/a> \u304b\u3089 <\/li>\n<\/ul>\n<h3><strong>3.Java \u3067 \u30ea\u30af\u30a8\u30b9\u30c8\u3092\u51e6\u7406\u3059\u308b<\/strong><\/h3>\n<p>\u6700\u7d42\u7684\u306bPython\u3067\u3001\u30b5\u30f3\u30d7\u30eb\u3092\u4f5c\u6210\u3057\u305f\u304c\u3001\u6700\u521dJava\u3067\u3084\u308d\u3046\u3068\u601d\u3044\u9014\u4e2d\u307e\u3067\u78ba\u8a8d\u3057\u305f\u306e\u3067\u4e00\u5fdc\u624b\u9806\u3092\u30e1\u30e2\u3057\u3066\u304a\u304f\u3002<\/p>\n<p>web\u30b5\u30fc\u30d3\u30b9\u3092\u547c\u3073\u51fa\u3059\u3053\u3068\u306b\u3088\u3063\u3066\u3001<a href=\"http:\/\/docs.amazonwebservices.com\/AWSECommerceService\/latest\/GSG\/\">Product Advertising API \u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30b5\u30a4\u30c9\u30e9\u30a4\u30d6\u30e9\u30ea\u30b9\u30bf\u30d6\u304c\u81ea\u52d5\u751f\u6210<\/a>\u3055\u308c\u308b\u3002<\/p>\n<p>Eclipse \u3067\u3001AmazonWsStub\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u305f\u3068\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u624b\u9806<\/p>\n<h4>(1) \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u69cb\u6210<\/h4>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\" width=\"184\">\n<tbody>\n<tr>\n<td class=\"code\" valign=\"top\" width=\"182\"><font face=\"Arial\">AmazonWsStub            <br \/>\u251c\u2500bin             <br \/>\u251c\u2500src             <br \/>\u2514\u2500jaxws-custom.xml<\/font> <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>(2)jaxws-custom.xml \u306e\u5185\u5bb9<\/h4>\n<pre class=\"prettyprint linenums\">&lt;jaxws:bindings wsdlLocation=&quot;http:\/\/ecs.amazonaws.com\/AWSECommerceService\/AWSECommerceService.wsdl&quot; xmlns:jaxws=&quot;http:\/\/java.sun.com\/xml\/ns\/jaxws&quot;&gt;\r\n  &lt;jaxws:enableWrapperStyle&gt;false&lt;\/jaxws:enableWrapperStyle&gt;\r\n&lt;\/jaxws:bindings&gt;<\/pre>\n<h4>(3) WebService Import \u3092\u5b9f\u884c\u3059\u308b\u30b3\u30de\u30f3\u30c9<\/h4>\n<pre class=\"prettyprint linenums\">wsimport -d .\/bin -s .\/src  -p com.ECS.client.jax http:\/\/ecs.amazonaws.com\/AWSECommerceService\/AWSECommerceService.wsdl -b jaxws-custom.xml<\/pre>\n<h6>&#160; <a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/AmazonProductAdvertisingAPIPython_14AC8\/ama_py04.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" border=\"0\" alt=\"ama_py04\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/AmazonProductAdvertisingAPIPython_14AC8\/ama_py04_thumb.jpg\" width=\"244\" height=\"139\" \/><\/a> <\/h6>\n<p><font color=\"#8080ff\">\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u69d8\u5b50<\/font><\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/AmazonProductAdvertisingAPIPython_14AC8\/ama_py05.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" border=\"0\" alt=\"ama_py05\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/AmazonProductAdvertisingAPIPython_14AC8\/ama_py05_thumb.jpg\" width=\"244\" height=\"172\" \/><\/a> <\/p>\n<p><font color=\"#8080ff\">Java \u30af\u30e9\u30b9\u7fa4\u304c\u81ea\u52d5\u4f5c\u6210\u3055\u308c\u305f<\/font><\/p>\n<h4>(4) \u30b5\u30f3\u30d7\u30eb\u3092\u4f5c\u6210\u3057\u3066\u52d5\u304b\u3057\u3066\u307f\u308b\u3002<\/h4>\n<pre class=\"prettyprint linenums\">package info.typea.test.ecs;\r\n\r\nimport java.util.List;\r\n\r\nimport com.ECS.client.jax.AWSECommerceService;\r\nimport com.ECS.client.jax.AWSECommerceServicePortType;\r\nimport com.ECS.client.jax.Item;\r\nimport com.ECS.client.jax.ItemAttributes;\r\nimport com.ECS.client.jax.ItemSearch;\r\nimport com.ECS.client.jax.ItemSearchRequest;\r\nimport com.ECS.client.jax.ItemSearchResponse;\r\nimport com.ECS.client.jax.Items;\r\n\r\npublic class ProductAdvertisingAPITest {\r\n\r\n    public static void main(String[] args) {\r\n        ProductAdvertisingAPITest me = new ProductAdvertisingAPITest();\r\n        me.itemSearchTest();\r\n    }\r\n    public void itemSearchTest() {\r\n        \/\/ \u30b5\u30fc\u30d3\u30b9\u306e\u30bb\u30c3\u30c8\r\n        AWSECommerceService service = new AWSECommerceService();\r\n        \/\/ \u30b5\u30fc\u30d3\u30b9\u306e\u30dd\u30fc\u30c8\u3092\u30bb\u30c3\u30c8\r\n        AWSECommerceServicePortType port = service.getAWSECommerceServicePort();\r\n        \/\/ \u30aa\u30da\u30ec\u30fc\u30b7\u30e7\u30f3\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u53d6\u5f97\r\n        ItemSearchRequest request = new ItemSearchRequest();\r\n        \/\/ \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u8a2d\u5b9a\r\n        request.setSearchIndex(&quot;Books&quot;);\r\n        request.setKeywords(&quot;dog&quot;);\r\n        ItemSearch itemSearch = new ItemSearch();\r\n        itemSearch.setAWSAccessKeyId(&quot;*************&quot;);  \/\/ Dummy\r\n        itemSearch.getRequest().add(request);\r\n        \/\/ Web\u30b5\u30fc\u30d3\u30b9\u3092\u547c\u3073\u51fa\u3057\u5fdc\u7b54\u3092\u683c\u7d0d\r\n        ItemSearchResponse response = port.itemSearch(itemSearch);\r\n\r\n        \/\/ \u7d50\u679c\u3092\u8868\u793a\r\n        System.out.println(&quot;-- print item search result --&quot;);\r\n        List&lt;Items&gt; itemslist = response.getItems();\r\n        for (Items items : itemslist) {\r\n            List&lt;Item&gt; itemlist = items.getItem();\r\n            for (Item item : itemlist) {\r\n                ItemAttributes attr = item.getItemAttributes();\r\n                System.out.format(\r\n                        &quot;%s %s %s %s\\n&quot;,\r\n                        item.getASIN(),\r\n                        attr.getTitle(),\r\n                        attr.getAuthor().get(0),\r\n                        item.getDetailPageURL()\r\n                );\r\n            }\r\n        }\r\n    }\r\n}<\/pre>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/AmazonProductAdvertisingAPIPython_14AC8\/ama_py06.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" border=\"0\" alt=\"ama_py06\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/AmazonProductAdvertisingAPIPython_14AC8\/ama_py06_thumb.jpg\" width=\"379\" height=\"129\" \/><\/a> <\/p>\n<p>\u7d50\u679c\u304c\u5e30\u3063\u3066\u304d\u305f\u30fb\u30fb\u30fb \u306e\u306f\u3044\u3044\u3051\u3069\u3001\u3069\u3046\u3082\u3001\u3071\u3063\u3068\u898b\u3001\u4eca\u56de\u554f\u984c\u3068\u3057\u3066\u3044\u308b Secret Access Key \u304c\u73fe\u6642\u70b9\u3067\u306f\u6307\u5b9a\u3067\u304d\u306a\u3055\u305d\u3046\uff1fSOAP\uff1f\u3053\u308c\u306b<a href=\"https:\/\/affiliate.amazon.co.jp\/gp\/associates\/help\/t126\/a11?ie=UTF8&amp;pf_rd_t=501&amp;ref_=amb_link_84046416_3&amp;pf_rd_m=AN1VRQENFRJN5&amp;pf_rd_p=&amp;pf_rd_s=center-1&amp;pf_rd_r=&amp;pf_rd_i=assoc_help_t126_a9\">\u7f72\u540d\u8a08\u7b97\u3092\u57cb\u3081\u8fbc\u3080<\/a>\uff1f\uff1f\uff1f\u307e\u3041Python\u3092\u899a\u3048\u305f\u3044\u306e\u3067\u3001Python\u3067\u3084\u3063\u3066\u307f\u3088\u3046\u3002<\/p>\n<p>&#160;<\/p>\n<h3><strong>4. Python\u3067\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u4f5c\u6210\u3059\u308b<\/strong><\/h3>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001Python\u3067\u3084\u3063\u3066\u307f\u308b\u3002\u4eca\u56de\u306f\u7f72\u540d\u4ed8\u304dREST\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u4f5c\u6210\u3059\u308b\u3068\u3053\u308d\u307e\u3067\u3002<\/p>\n<p>REST\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u8a73\u7d30\u306f\u3001<a title=\"http:\/\/docs.amazonwebservices.com\/AWSECommerceService\/latest\/DG\/index.html?AnatomyOfaRESTRequest.html\" href=\"http:\/\/docs.amazonwebservices.com\/AWSECommerceService\/latest\/DG\/index.html?AnatomyOfaRESTRequest.html\">http:\/\/docs.amazonwebservices.com\/AWSECommerceService\/latest\/DG\/index.html?AnatomyOfaRESTRequest.html<\/a> \u3053\u306e\u3042\u305f\u308a\u3092\u53c2\u7167\u3002<\/p>\n<p>\u57fa\u672c\u7684\u306b\u306f\u3001<a href=\"https:\/\/affiliate.amazon.co.jp\/gp\/associates\/help\/t126\/a10?ie=UTF8&amp;pf_rd_t=501&amp;ref_=amb_link_84046416_2&amp;pf_rd_m=AN1VRQENFRJN5&amp;pf_rd_p=&amp;pf_rd_s=center-1&amp;pf_rd_r=&amp;pf_rd_i=assoc_help_t126_a9\">\u7f72\u540d\u306e\u4f5c\u6210\u65b9\u6cd5<\/a>\u306b\u5f93\u3063\u305f\u3001REST\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n<p><a href=\"http:\/\/d.hatena.ne.jp\/niiyan\/20090509\/1241884365\">\u3053\u306e<\/a>\u30b5\u30a4\u30c8\u3092\u5927\u3044\u306b\u53c2\u8003\u306b\u3055\u305b\u3066\u3044\u305f\u3060\u3044\u305f\u611f\u8b1d\u3002<\/p>\n<h4>(1) \u57fa\u672c\u30a4\u30e1\u30fc\u30b8<\/h4>\n<p>Amazon Product Advertising API \u306f \u3056\u3063\u304f\u308a Operation \u3068\u3057\u3066\u3001\u884c\u3044\u305f\u3044\u64cd\u4f5c(\u305f\u3068\u3048\u3070ItemSearch\uff09\u3092\u30d1\u30e9\u30e1\u30fc\u30bf(\u305f\u3068\u3048\u3070Keywords)\u3068\u3068\u3082\u306b\u6307\u5b9a\u3057\u305f\u30ea\u30af\u30a8\u30b9\u30c8\u3092REST\u3084SOAP\u3067\u9001\u4fe1\u3057\u3001\u7d50\u679c\u3092XML\u3067\u53d6\u5f97\u3059\u308b\u3002<\/p>\n<p><a href=\"http:\/\/www.amazon.co.jp\/gp\/product\/4756146759?ie=UTF8&amp;tag=typea09-22&amp;linkCode=as2&amp;camp=247&amp;creative=7399&amp;creativeASIN=4756146759\">\u4ffa\u6d41amazon\u306e\u4f5c\u308a\u65b9\u2015Amazon Web\u30b5\u30fc\u30d3\u30b9\u6700\u65b0\u6d3b\u7528\u30c6\u30af\u30cb\u30c3\u30af<\/a><img loading=\"lazy\" decoding=\"async\" style=\"border-bottom-style: none !important; border-right-style: none !important; margin: 0px; border-top-style: none !important; border-left-style: none !important\" border=\"0\" alt=\"\" src=\"http:\/\/www.assoc-amazon.jp\/e\/ir?t=typea09-22&amp;l=as2&amp;o=9&amp;a=4756146759\" width=\"1\" height=\"1\" \/> <\/p>\n<p>\u307e\u305a\u306f\u3001\u7f72\u540d\u3092\u3064\u3051\u305f\u30ea\u30af\u30a8\u30b9\u30c8\u304c\u6b63\u3057\u304f\u53d7\u7406\u3055\u308c\u308b\u3053\u3068\u304c\u76ee\u6a19\u306a\u306e\u3067\u3001Oparation \u57fa\u5e95\u30af\u30e9\u30b9\u306b\u305d\u306e\u3042\u305f\u308a\u306e\u57fa\u672c\u6a5f\u80fd\u3092\u5b9f\u88c5\u3057\u3001\u500b\u5225\u306e\u64cd\u4f5c\u306f\u305d\u306e\u6d3e\u751f\u30af\u30e9\u30b9(\u307e\u305f\u306f\u6c4e\u7528\u30af\u30e9\u30b9)\u3068\u3057\u3066\u3064\u3069\u4f5c\u3063\u3066\u3044\u3051\u3070\u3088\u3044\u304b\u306a\u3068\u3002<\/p>\n<h4>(2) \u624b\u9806<\/h4>\n<p><a href=\"https:\/\/affiliate.amazon.co.jp\/gp\/associates\/help\/t126\/a10?ie=UTF8&amp;pf_rd_t=501&amp;ref_=amb_link_84046416_2&amp;pf_rd_m=AN1VRQENFRJN5&amp;pf_rd_p=&amp;pf_rd_s=center-1&amp;pf_rd_r=&amp;pf_rd_i=assoc_help_t126_a9\">\u7f72\u540d\u306e\u4f5c\u6210\u65b9\u6cd5<\/a>\u306b\u3001\u7f72\u540d\u3064\u304dREST\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u4f5c\u6210\u624b\u9806\u304c\u8f09\u3063\u3066\u3044\u308b\u304c\u3001\u3053\u308c\u3060\u3051\u3067\u306f\u5b9f\u969b\u308f\u304b\u308a\u306b\u304f\u3044\u3002<\/p>\n<p><a href=\"http:\/\/developer.amazonwebservices.com\/connect\/entry.jspa?externalID=2609&amp;categoryID=14\">Product Advertising API Signed Requests Helper<\/a> \u3068\u3044\u3046\u30c4\u30fc\u30eb\u304c\u63d0\u4f9b\u3055\u308c\u3066\u304a\u308a(Web \u3082\u3057\u304f\u306f \u30c0\u30a6\u30f3\u30ed\u30fc\u30c9)\u3001\u3053\u308c\u3092\u78ba\u8a8d\u3059\u308b\u3068\u3001\u4e0a\u8a18\u7f72\u540d\u306e\u4f5c\u6210\u624b\u9806\u306e\u9014\u4e2d\u7d4c\u904e\u304c\u3001\u9806\u3092\u8ffd\u3063\u3066\u78ba\u8a8d\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u3002<\/p>\n<p>AWS Access Key ID \u3068AWS Secret Access Key\u3068\u672a\u7f72\u540d\u306eREST\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u5165\u529b\u3057\u3066\u3001Display Signed URL \u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3068\u30fb\u30fb\u30fb<a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/AmazonProductAdvertisingAPIPython_14AC8\/ama_py07.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" border=\"0\" alt=\"ama_py07\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/AmazonProductAdvertisingAPIPython_14AC8\/ama_py07_thumb.jpg\" width=\"326\" height=\"149\" \/><\/a> <\/p>\n<p><font color=\"#8080ff\">Unsigned URL : \u672a\u7f72\u540d\u306eREST\u30ea\u30af\u30a8\u30b9\u30c8\u304c\u30fb\u30fb\u30fb<\/font><\/p>\n<p><font color=\"#8080ff\">Name-Value Paires : KEY\u540d\u3068\u5024\u306e\u30da\u30a2\u306b\u5206\u5272\u3055\u308c\u3001TimeStamp\u304c\u306a\u3051\u308c\u3070\u4ed8\u4e0e<\/font><\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/AmazonProductAdvertisingAPIPython_14AC8\/ama_py08.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" border=\"0\" alt=\"ama_py08\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/AmazonProductAdvertisingAPIPython_14AC8\/ama_py08_thumb.jpg\" width=\"321\" height=\"226\" \/><\/a> <\/p>\n<p><font color=\"#8080ff\">Sorted Pairs : \u30bd\u30fc\u30c8\u3055\u308c\u30fb\u30fb\u30fb<\/font><\/p>\n<p><font color=\"#8080ff\">String-To-Sign : \u96fb\u5b50\u7f72\u540d\u7528\u306e\u6587\u5b57\u5217\u304c\u751f\u6210\u3055\u308c\u30fb\u30fb\u30fb<\/font><\/p>\n<p><font color=\"#8080ff\">Signed URL : \u7f72\u540d\u3055\u308c\u305fURL\u304c\u751f\u6210\u3055\u308c\u308b<\/font><\/p>\n<p>\u306e\u3067\u3001\u3053\u306e\u7d50\u679c\u3092\u78ba\u8a8d\u3057\u306a\u304c\u3089\u3001\u540c\u3058\u51fa\u529b\u304c\u5f97\u3089\u308c\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u3051\u3070\u3088\u3044\u3002<\/p>\n<h4>(3) Python \u30b5\u30f3\u30d7\u30eb\u30bd\u30fc\u30b9<\/h4>\n<p><a href=\"http:\/\/docs.amazonwebservices.com\/AWSECommerceService\/latest\/DG\/index.html?ItemSearch.html\">ItemSearch API<\/a> \u3092\u5229\u7528\u3059\u308b\u30b5\u30f3\u30d7\u30eb\u3092\u4f5c\u6210\u3057\u3066\u307f\u305f\u3002<\/p>\n<p>\u57fa\u672c\u7684\u306b\u306f\u3001\u7d20\u76f4\u306b\u3001\u5b9f\u88c5\u3057\u305f\u3064\u3082\u308a\u3002<\/p>\n<p>URL \u30a8\u30f3\u30b3\u30fc\u30c9 <a href=\"http:\/\/www.ietf.org\/rfc\/rfc2396.txt\">RFC 2396<\/a><\/p>\n<p>\u30bf\u30a4\u30e0\u30b9\u30bf\u30f3\u30d7 : <a href=\"http:\/\/ja.wikipedia.org\/wiki\/ISO_8601\">ISO 8601<\/a><\/p>\n<p>\u3042\u305f\u308a\u3092\u53c2\u8003\u306b\u3002<\/p>\n<pre class=\"prettyprint linenums\">#!Python2.6\r\n# -*- coding: utf-8 -*-\r\nimport urllib\r\nfrom datetime import datetime\r\nimport hashlib, hmac\r\nimport base64\r\n\r\n#@see: http:\/\/d.hatena.ne.jp\/niiyan\/20090509\/1241884365\r\nclass Operation:\r\n    __safe_chars = '-._~'\r\n    __ecs_url = 'http:\/\/ecs.amazonaws.jp\/onca\/xml'\r\n    __service = 'AWSECommerceService'\r\n    __access_key_id = '***********' # Dummy\r\n    __associate_tag = '*******' # Dummy\r\n    __secret_access_key = '**********************' # Dummy\r\n    __http_verb = 'GET'\r\n    __value_of_host_header_in_lowercase = '\/onca\/xml'\r\n    __http_request_uri = 'ecs.amazonaws.jp'\r\n    def __init__(self):\r\n\r\n        self.__param_map = {}\r\n\r\n\r\n    def operation_name(self):\r\n        return ''\r\n\r\n    def request(self):\r\n        self.set_parameter('Service', self.__service)\r\n        self.set_parameter('AWSAccessKeyId', self.__access_key_id)\r\n        self.set_parameter('AssociateTag', self.__associate_tag)\r\n        self.set_parameter('Operation', self.operation_name())\r\n        self.set_parameter('Timestamp', datetime.utcnow().isoformat() + 'Z')\r\n        #Name-Value Pairs\r\n        n_v_pair_list = []\r\n        for key in self.__param_map.keys():\r\n            n_v_pair_list.append(urllib.quote(key, self.__safe_chars) + '=' + urllib.quote(self.__param_map[key], self.__safe_chars))\r\n\r\n        #Sorted Pairs\r\n        n_v_pair_list.sort()\r\n        request_parm_str = '&amp;'.join(n_v_pair_list)\r\n        #String-To-Sign\r\n        sing_part_list = [self.__http_verb, self.__http_request_uri, self.__value_of_host_header_in_lowercase, request_parm_str]\r\n        str_to_sign = '\\n'.join(sing_part_list)\r\n        hmac_digest = hmac.new(self.__secret_access_key, str_to_sign, hashlib.sha256).digest()\r\n        base64_encoded = base64.b64encode(hmac_digest)\r\n        signature = urllib.quote(base64_encoded);\r\n        return '%s?%s&amp;Signature=%s' % (self.__ecs_url, request_parm_str, signature)\r\n    def set_parameter(self, key, value='', remove=False):\r\n        if remove:\r\n            del self.__param_map[key]\r\n        else:\r\n            self.__param_map[key] = value\r\n    def response_group(self, value='', remove=False):\r\n        self.set_parameter('ResponseGroup', value='Medium', remove=False)\r\n\r\nclass ItemSearch(Operation):\r\n    '''\r\n    @see: http:\/\/docs.amazonwebservices.com\/AWSECommerceService\/latest\/DG\/index.html?ItemSearch.html\r\n    '''\r\n    def operation_name(self):\r\n        return 'ItemSearch'\r\n    def keywords(self, value, remove=False):\r\n        self.set_parameter('Keywords', value, remove)\r\n    def search_index(self, value='Books', remove=False):\r\n        self.set_parameter('SearchIndex', value, remove)\r\n\r\nrequest = ItemSearch()\r\nrequest.keywords('\u624b\u585a \u6cbb\u866b')\r\nrequest.search_index('Books')\r\nrequest.response_group('Reviews')\r\nprint request.request() \r\n<\/pre>\n<p>\u7d50\u679c\u4f5c\u6210\u3055\u308c\u305f URL <\/p>\n<p><a title=\"http:\/\/ecs.amazonaws.jp\/onca\/xml?AWSAccessKeyId=1498TGK1YPN1JATPXXG2&amp;AssociateTag=typea09-22&amp;Keywords=%E6%89%8B%E5%A1%9A%E3%80%80%E6%B2%BB%E8%99%AB&amp;Operation=ItemSearch&amp;ResponseGroup=Medium&amp;SearchIndex=Books&amp;Service=AWSECommerceService&amp;Timestamp=2009-07-29T15%3A57%3A09.593000Z&amp;Signature=QwyP%2BmIsLJSoZZVEvO0ps5zPHfXZ1vevY\/4sRiR7pAo%3D\" href=\"http:\/\/ecs.amazonaws.jp\/onca\/xml?AWSAccessKeyId=1498TGK1YPN1JATPXXG2&amp;AssociateTag=typea09-22&amp;Keywords=%E6%89%8B%E5%A1%9A%E3%80%80%E6%B2%BB%E8%99%AB&amp;Operation=ItemSearch&amp;ResponseGroup=Medium&amp;SearchIndex=Books&amp;Service=AWSECommerceService&amp;Timestamp=2009-07-29T15%3A57%3A09.593000Z&amp;Signature=QwyP%2BmIsLJSoZZVEvO0ps5zPHfXZ1vevY\/4sRiR7pAo%3D\">http:\/\/ecs.amazonaws.jp\/onca\/xml?AWSAccessKeyId=1498TGK1YPN1JATPXXG2&amp;AssociateTag=typea09-22&amp;Keywords=%E6%89%8B%E5%A1%9A%E3%80%80%E6%B2%BB%E8%99%AB&amp;Operation=ItemSearch&amp;ResponseGroup=Medium&amp;SearchIndex=Books&amp;Service=AWSECommerceService&amp;Timestamp=2009-07-29T15%3A57%3A09.593000Z&amp;Signature=QwyP%2BmIsLJSoZZVEvO0ps5zPHfXZ1vevY\/4sRiR7pAo%3D<\/a><\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/AmazonProductAdvertisingAPIPython_14AC8\/ama_py09.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" border=\"0\" alt=\"ama_py09\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/AmazonProductAdvertisingAPIPython_14AC8\/ama_py09_thumb.jpg\" width=\"301\" height=\"255\" \/><\/a> <\/p>\n<p>\u6b63\u3057\u304f\u8a8d\u8a3c\u3055\u308c\u3066\u3001\u7d50\u679c\u304c\u8fd4\u3063\u3066\u304d\u305f\u3002<\/p>\n<p>\u307e\u305f\u4e00\u6b69\u91ce\u671b\u306b\u8fd1\u3065\u3044\u305f\uff01<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Amazon \u30a2\u30bd\u30b7\u30a8\u30a4\u30c8 Web \u30b5\u30fc\u30d3\u30b9\u306e\u540d\u79f0\u304c\u3001\u300cProduct Advertising API\u300d\u306b\u5909\u308f\u308a\u3001\u96fb\u5b50\u7f72\u540d\u3092 8\u670815\u65e5\u307e\u3067\u306b\u30ea\u30af\u30a8\u30b9\u30c8\u306b\u542b\u3081\u308b\u5fc5\u8981\u304c\u3042\u308b\u65e8\u306e\u30e1\u30fc\u30eb\u304c\u5148\u65e5\u5c4a\u3044\u305f\u3002 GAE\/Python \u4e0a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"sns_share_botton_hide":"","vkExUnit_sns_title":"","_vk_print_noindex":"","sitemap_hide":"","_veu_custom_css":"","veu_display_promotion_alert":"","vkexunit_cta_each_option":"","footnotes":""},"categories":[25,20],"tags":[],"class_list":["post-148","post","type-post","status-publish","format-standard","hentry","category-amazon-web-services","category-python"],"veu_head_title_object":{"title":"","add_site_title":""},"_links":{"self":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/148","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=148"}],"version-history":[{"count":0,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/148\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=148"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}