{"id":866,"date":"2010-11-29T22:28:43","date_gmt":"2010-11-29T13:28:43","guid":{"rendered":"http:\/\/peta.okechan.net\/blog\/?p=866"},"modified":"2010-11-29T23:03:01","modified_gmt":"2010-11-29T14:03:01","slug":"amazon%e3%81%ae%e5%95%86%e5%93%81%e5%80%8b%e5%88%a5%e3%83%9a%e3%83%bc%e3%82%b8%e3%81%aeurl%e3%81%8b%e3%82%89asin%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b-%e3%81%9d%e3%81%ae%ef%bc%92","status":"publish","type":"post","link":"https:\/\/peta.okechan.net\/blog\/archives\/866","title":{"rendered":"Amazon\u306e\u5546\u54c1\u500b\u5225\u30da\u30fc\u30b8\u306eURL\u304b\u3089ASIN\u3092\u53d6\u5f97\u3059\u308b \u305d\u306e\uff12"},"content":{"rendered":"<p>\u3053\u306e\u524d\u66f8\u3044\u305f<a href=\"https:\/\/peta.okechan.net\/blog\/archives\/852\">Amazon\u306e\u5546\u54c1\u500b\u5225\u30da\u30fc\u30b8\u306eURL\u304b\u3089ASIN\u3092\u53d6\u5f97\u3059\u308b<\/a>\u3068\u3044\u3046\u30a8\u30f3\u30c8\u30ea\u306b\u8f09\u305b\u305f\u3001\u30a6\u30ce\u30a6\u306e\u30a2\u30ec\u3092\u79fb\u690d\u3057\u305f\u95a2\u6570\u3067\u8272\u3005\u8a66\u3057\u3066\u307f\u3066\u305f\u3068\u3053\u308d\u3001\u306a\u3093\u304b\u601d\u3063\u305f\u3088\u308a\u3082ASIN\u3092\u62bd\u51fa\u51fa\u6765\u308b\u5272\u5408\u304c\u5c11\u306a\u3044\u3068\u3044\u3046\u304b\u53d6\u308a\u3053\u307c\u3057\u304c\u591a\u3044\u3093\u3058\u3083\u306a\u3044\u304b\u3068\u3044\u3046\u6c17\u304c\u3057\u305f\u305f\u3081\u3001\u771f\u9762\u76ee\u306b\u81ea\u529b\u3067\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\u3002\uff08\u6b63\u76f4\u6c5a\u306d\u3047\u30b3\u30fc\u30c9\u3060\u306a\u30fc\u3068\u3082\u601d\u3063\u3066\u305f\u3057\u3002\uff09<\/p>\n<p>\u51e6\u7406\u5185\u5bb9\u306f\u3001amazon\u306eurl\u304b\u30c1\u30a7\u30c3\u30af\u3057\u3066\u3001\u3082\u3057\u305d\u3046\u306a\u3089asin\u3092\u542b\u3080\u304b\u3069\u3046\u304b\u30c1\u30a7\u30c3\u30af\u3059\u308b\u3068\u3044\u3046\u611f\u3058\u3067\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\ndef get_asin_from_url(url):\r\n\t'''url\u304b\u3089asin\u3092\u62bd\u51fa'''\r\n\turl = url.lower()\r\n\tamazon_r = re.compile(r'^https?:\/\/(?:&#x5B;^.]+\\.)?(?:images-)?amazon\\.(?:com|ca|co\\.uk|de|co\\.jp|jp|fr|cn)(\/.+)$')\r\n\tamazon = amazon_r.match(url)\r\n\tif not amazon:\r\n\t\treturn None\r\n\t\r\n\tpath = amazon.group(1)\r\n\t\r\n\tpattern = '''\r\n\t(?:\t# \u4ee5\u4e0b\u306e\u30d1\u30bf\u30fc\u30f3\u306e\u3044\u305a\u308c\u304b\u304b\u3089\u59cb\u307e\u308a\uff08\u4e00\u5fdcURL\u30a8\u30f3\u30b3\u30fc\u30c9\u3057\u305f\u5024\u3082\u4f75\u8a18\uff09\r\n\t\t\/asin\/| %2fasin%2f|\r\n\t\t&amp;asins?=| %26asins?%3d|\r\n\t\t=asin\/| %3dasin%2f|\r\n\t\t&amp;a=| %26a%3d|\r\n\t\t\/dp\/| %2fdp%2f|\r\n\t\t\/dp\/accessories\/| %2fdp%2faccessories%2f|\r\n\t\t\/dp\/artist-redirect\/| %2fdp%2fartist-redirect%2f|\r\n\t\t\/dp\/product-details\/| %2fdp%2fproduct-details%2f|\r\n\t\t\/dp\/samples\/| %2fdp%2fsamples%2f|\r\n\t\t\/exec\/obidos\/isbn\/| %2fexec%2fobidos%2fisbn%2f|\r\n\t\t\/gp\/offer-listing\/| %2fgp%2foffer-listing%2f|\r\n\t\t\/gp\/product\/| %2fgp%2fproduct%2f|\r\n\t\t\/gp\/product\/images\/| %2fgp%2fproduct%2fimages%2f|\r\n\t\t\/gp\/product\/product-description\/| %2fgp%2fproduct%2fproduct-description%2f|\r\n\t\t\/gp\/product\/toc\/| %2fgp%2fproduct%2ftoc%2f|\r\n\t\t\/images\/p\/| %2fimages%2fp%2f|\r\n\t\t\/product-reviews\/| %2fproduct-reviews%2f|\r\n\t\t\/sim\/| %2fsim%2f\t# \u6700\u5f8c\u306f\u7e26\u68d2\u3092\u4ed8\u3051\u306a\u3044\uff01\r\n\t)\r\n\t(&#x5B;0-9a-z]{10}) # The ASIN!\r\n\t(?:\t# \u4ee5\u4e0b\u306e\u30d1\u30bf\u30fc\u30f3\u306e\u3044\u305a\u308c\u304b\u3067\u7d42\u308f\u308b\r\n\t\t\/|\r\n\t\t\\?|\r\n\t\t&amp;|\r\n\t\t\\.|\r\n\t\t%|\r\n\t\t$\r\n\t)\r\n\t'''\r\n\tasin_r = re.compile(pattern, re.VERBOSE)\r\n\tasin = asin_r.search(path)\r\n\tif asin:\r\n\t\treturn asin.group(1).upper()\r\n\telse:\r\n\t\treturn None\r\n<\/pre>\n<p>\u3067\u307e\u3041\u3001\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u3068\u3057\u3066asin\u3092\u542b\u3080\u304b\u3069\u3046\u304b\u306b\u9650\u3089\u305a\u69d8\u3005\u306a\u30d1\u30bf\u30fc\u30f3\u306eamazon\u306eurl\u3092\u7d0418,000\u4ef6\u3050\u3089\u3044\u7528\u610f\u3057\u307e\u3057\u3066\u3001\u4eca\u56de\u306e\u95a2\u6570\u3068\u524d\u56de\u306e\u95a2\u6570\u306b\u304b\u3051\u3066\u307f\u307e\u3057\u305f\u3002<br \/>\n\u4eca\u56de\u306e\u95a2\u6570\u3060\u3068\u3001\u7d0418,000\u4ef6\u4e2d\u7d0416,000\u4ef6\u304b\u3089asin\u3092\u62bd\u51fa\u51fa\u6765\u307e\u3057\u305f\u3002<br \/>\n\u3082\u3061\u308d\u3093\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u3068\u76ee\u8996\u3067\u3056\u3063\u3068\u78ba\u8a8d\u3057\u305f\u3068\u3053\u308d\u3001\u304a\u304b\u3057\u3044\u70b9\u306f\u898b\u5f53\u305f\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u3002\uff08\u53d6\u308a\u3053\u307c\u3057\u3084\u3001asin\u3058\u3083\u306a\u3044\u3082\u306e\u3092\u8aa4\u8a8d\u8b58\u3059\u308b\u4e8b\u306f\u7121\u3044\u3088\u3046\u3067\u3057\u305f\u3002\uff09<br \/>\n\u3082\u3061\u308d\u3093\u7cbe\u5ea6100%\u3067\u306f\u306a\u3044\u3068\u601d\u3044\u307e\u3059\u304c\u3002<br \/>\n\u4e00\u65b9\u3001\u524d\u56de\u306e\u95a2\u6570\u3060\u3068\u3001\u7d0418,000\u4ef6\u4e2d\u7d047,000\u4ef6\u3057\u304basin\u3092\u62bd\u51fa\u51fa\u6765\u307e\u305b\u3093\u3067\u3057\u305f\u3002<\/p>\n<p>\u30c0\u30e1\u3063\u3059\u306d\u3002\u30a6\u30ce\u2026\u30b2\u30d5\u30f3\u30b2\u30d5\u30f3<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u306e\u524d\u66f8\u3044\u305f<a href=\"https:\/\/peta.okechan.net\/blog\/archives\/852\">Amazon\u306e\u5546\u54c1\u500b\u5225\u30da\u30fc\u30b8\u306eURL\u304b\u3089ASIN\u3092\u53d6\u5f97\u3059\u308b<\/a>\u3068\u3044\u3046\u30a8\u30f3\u30c8\u30ea\u306b\u8f09\u305b\u305f\u3001\u30a6\u30ce\u30a6\u306e\u30a2\u30ec\u3092\u79fb\u690d\u3057\u305f\u95a2\u6570\u3067\u8272\u3005\u8a66\u3057\u3066\u307f\u3066\u305f\u3068\u3053\u308d\u3001\u306a\u3093\u304b\u601d\u3063\u305f\u3088\u308a\u3082ASIN\u3092\u62bd\u51fa\u51fa\u6765\u308b\u5272\u5408\u304c\u5c11\u306a\u3044\u3068\u3044\u3046\u304b\u53d6\u308a\u3053\u307c\u3057\u304c\u591a\u3044\u3093\u3058\u3083\u306a\u3044\u304b\u3068\u3044\u3046\u6c17\u304c\u3057\u305f\u305f\u3081\u3001\u771f\u9762\u76ee\u306b\u81ea\u529b\u3067\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\u3002\uff08\u6b63\u76f4\u6c5a\u306d\u3047\u30b3\u30fc\u30c9\u3060\u306a\u30fc\u3068\u3082\u601d\u3063\u3066\u305f\u3057\u3002\uff09<\/p>\n<p>\u51e6\u7406\u5185\u5bb9\u306f\u3001amazon\u306eurl\u304b\u30c1\u30a7\u30c3\u30af\u3057\u3066\u3001\u3082\u3057\u305d\u3046\u306a\u3089asin\u3092\u542b\u3080\u304b\u3069\u3046\u304b\u30c1\u30a7\u30c3\u30af\u3059\u308b\u3068\u3044\u3046\u611f\u3058\u3067\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\ndef get_asin_from_url(url):\r\n\t'''url\u304b\u3089asin\u3092\u62bd\u51fa'''\r\n\turl = url.lower()\r\n\tamazon_r = re.compile(r'^https?:\/\/(?:&#x5B;^.]+\\.)?(?:images-)?amazon\\.(?:com|ca|co\\.uk|de|co\\.jp|jp|fr|cn)(\/.+)$')\r\n\tamazon = amazon_r.match(url)\r\n\tif not amazon:\r\n\t\treturn None\r\n\t\r\n\tpath = amazon.group(1)\r\n\t\r\n\tpattern = '''\r\n\t(?:\t# \u4ee5\u4e0b\u306e\u30d1\u30bf\u30fc\u30f3\u306e\u3044\u305a\u308c\u304b\u304b\u3089\u59cb\u307e\u308a\uff08\u4e00\u5fdcURL\u30a8\u30f3\u30b3\u30fc\u30c9\u3057\u305f\u5024\u3082\u4f75\u8a18\uff09\r\n\t\t\/asin\/| %2fasin%2f|\r\n\t\t&amp;asins?=| %26asins?%3d|\r\n\t\t=asin\/| %3dasin%2f|\r\n\t\t&amp;a=| %26a%3d|\r\n\t\t\/dp\/| %2fdp%2f|\r\n\t\t\/dp\/accessories\/| %2fdp%2faccessories%2f|\r\n\t\t\/dp\/artist-redirect\/| %2fdp%2fartist-redirect%2f|\r\n\t\t\/dp\/product-details\/| %2fdp%2fproduct-details%2f|\r\n\t\t\/dp\/samples\/| %2fdp%2fsamples%2f|\r\n\t\t\/exec\/obidos\/isbn\/| %2fexec%2fobidos%2fisbn%2f|\r\n\t\t\/gp\/offer-listing\/| %2fgp%2foffer-listing%2f|\r\n\t\t\/gp\/product\/| %2fgp%2fproduct%2f|\r\n\t\t\/gp\/product\/images\/| %2fgp%2fproduct%2fimages%2f|\r\n\t\t\/gp\/product\/product-description\/| %2fgp%2fproduct%2fproduct-description%2f|\r\n\t\t\/gp\/product\/toc\/| %2fgp%2fproduct%2ftoc%2f|\r\n\t\t\/images\/p\/| %2fimages%2fp%2f|\r\n\t\t\/product-reviews\/| %2fproduct-reviews%2f|\r\n\t\t\/sim\/| %2fsim%2f\t# \u6700\u5f8c\u306f\u7e26\u68d2\u3092\u4ed8\u3051\u306a\u3044\uff01\r\n\t)\r\n\t(&#x5B;0-9a-z]{10}) # The ASIN!\r\n\t(?:\t# \u4ee5\u4e0b\u306e\u30d1\u30bf\u30fc\u30f3\u306e\u3044\u305a\u308c\u304b\u3067\u7d42\u308f\u308b\r\n\t\t\/|\r\n\t\t\\?|\r\n\t\t&amp;|\r\n\t\t\\.|\r\n\t\t%|\r\n\t\t$\r\n\t)\r\n\t'''\r\n\tasin_r = re.compile(pattern, re.VERBOSE)\r\n\tasin = asin_r.search(path)\r\n\tif asin:\r\n\t\treturn asin.group(1).upper()\r\n\telse:\r\n\t\treturn None\r\n<\/pre>\n<p>\u3067\u307e\u3041\u3001\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u3068\u3057\u3066asin\u3092\u542b\u3080\u304b\u3069\u3046\u304b\u306b\u9650\u3089\u305a\u69d8\u3005\u306a\u30d1\u30bf\u30fc\u30f3\u306eamazon\u306eurl\u3092\u7d0418,000\u4ef6\u3050\u3089\u3044\u7528\u610f\u3057\u307e\u3057\u3066\u3001\u4eca\u56de\u306e\u95a2\u6570\u3068\u524d\u56de\u306e\u95a2\u6570\u306b\u304b\u3051\u3066\u307f\u307e\u3057\u305f\u3002<br \/>\n\u4eca\u56de\u306e\u95a2\u6570\u3060\u3068\u3001\u7d0418,000\u4ef6\u4e2d\u7d0416,000\u4ef6\u304b\u3089asin\u3092\u62bd\u51fa\u51fa\u6765\u307e\u3057\u305f\u3002<br \/>\n\u3082\u3061\u308d\u3093\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u3068\u76ee\u8996\u3067\u3056\u3063\u3068\u78ba\u8a8d\u3057\u305f\u3068\u3053\u308d\u3001\u304a\u304b\u3057\u3044\u70b9\u306f\u898b\u5f53\u305f\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u3002\uff08\u53d6\u308a\u3053\u307c\u3057\u3084\u3001asin\u3058\u3083\u306a\u3044\u3082\u306e\u3092\u8aa4\u8a8d\u8b58\u3059\u308b\u4e8b\u306f\u7121\u3044\u3088\u3046\u3067\u3057\u305f\u3002\uff09<br \/>\n\u3082\u3061\u308d\u3093\u7cbe\u5ea6100%\u3067\u306f\u306a\u3044\u3068\u601d\u3044\u307e\u3059\u304c\u3002<br \/>\n\u4e00\u65b9\u3001\u524d\u56de\u306e\u95a2\u6570\u3060\u3068\u3001\u7d0418,000\u4ef6\u4e2d\u7d047,000\u4ef6\u3057\u304basin\u3092\u62bd\u51fa\u51fa\u6765\u307e\u305b\u3093\u3067\u3057\u305f\u3002<\/p>\n<p>\u30c0\u30e1\u3063\u3059\u306d\u3002\u30a6\u30ce\u2026\u30b2\u30d5\u30f3\u30b2\u30d5\u30f3<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32],"tags":[360,363,60],"class_list":["post-866","post","type-post","status-publish","format-standard","hentry","category-tech","tag-amazon","tag-asin","tag-python"],"_links":{"self":[{"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/posts\/866","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/comments?post=866"}],"version-history":[{"count":0,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/posts\/866\/revisions"}],"wp:attachment":[{"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/media?parent=866"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/categories?post=866"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/tags?post=866"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}