{"id":283,"date":"2022-03-05T17:03:06","date_gmt":"2022-03-05T08:03:06","guid":{"rendered":"https:\/\/ubun2m.com\/?p=283"},"modified":"2023-02-12T16:27:37","modified_gmt":"2023-02-12T07:27:37","slug":"%e5%9b%bd%e7%ab%8b%e5%9b%bd%e4%bc%9a%e5%9b%b3%e6%9b%b8%e9%a4%a8%e3%82%b5%e3%83%bc%e3%83%81api%e3%82%92%e5%88%a9%e7%94%a8%e3%81%97%e3%81%9fkindle%e3%81%ae%e8%94%b5%e6%9b%b8%e6%95%b4%e7%90%86","status":"publish","type":"post","link":"https:\/\/ubun2m.com\/?p=283","title":{"rendered":"\u56fd\u7acb\u56fd\u4f1a\u56f3\u66f8\u9928\u30b5\u30fc\u30c1API\u3092\u5229\u7528\u3057\u305fKindle\u306e\u8535\u66f8\u6574\u7406"},"content":{"rendered":"\n<p>\u65e5\u672c\u5341\u9032\u5206\u985e\u6cd5\uff08NDC\uff09\u3067Kindle\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3092\u6574\u7406\u3059\u308b\u305f\u3081\u306e\u88dc\u52a9\u30c4\u30fc\u30eb\u3092\u4f5c\u3063\u305f\u3002python3\u3067\u52d5\u4f5c\u78ba\u8a8d\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-file=\"python_serchNDC\" data-lang=\"Python\"><code>import xml.etree.ElementTree\nimport urllib.parse\nimport requests\nimport csv\nimport re\n\nnamespaces = {&#39;openSearch&#39;:&#39;http:\/\/a9.com\/-\/spec\/opensearchrss\/1.0\/&#39;,\n                  &#39;dc&#39;:&#39;http:\/\/purl.org\/dc\/elements\/1.1\/&#39;,\n                  &#39;rdf&#39;:&#39;http:\/\/www.w3.org\/1999\/02\/22-rdf-syntax-ns#&#39;}\n\ndef searchNDC(title,author):\n\n    # \u691c\u7d22\u306b\u4e0d\u90fd\u5408\u306a\u8981\u7d20\u3092\u524a\u9664\n    title = re.sub(&#39;\u3010.+?\u3011&#39;, &#39; &#39;, title)\n    title = re.sub(&#39;\uff08.+?\uff09&#39;, &#39; &#39;, title)\n    title = re.sub(&#39;\u3008.+?\u3009&#39;, &#39; &#39;, title)\n    title = re.sub(&#39;\\(.+?\\)&#39;, &#39; &#39;, title)\n\n    title = title.replace(&#39;\u3000&#39;, &#39; &#39;)\n    author = author.replace(&#39;:&#39;, &#39; &#39;)\n\n    url = &quot;https:\/\/iss.ndl.go.jp\/api\/opensearch?cnt=5&title=&quot; + urllib.parse.quote(title) + &quot;&creator=&quot; + urllib.parse.quote(author) +  &quot;&dpid=iss-ndl-opac&quot;\n\n    res = requests.get(url)\n    root = xml.etree.ElementTree.fromstring(res.text)\n\n    totalResults = root.findall(&#39;.\/\/openSearch:totalResults&#39;,namespaces) \n    for title_element in totalResults:\n            print(&quot;Results=&quot; + title_element.text + &quot; Search=&quot; + title + &quot; &quot; + author)\n        \n    for item in root.iter(&#39;item&#39;):\n        \n        ary=[]\n        for name in item.iter(&#39;title&#39;):\n            ary.append(name.text)\n        \n        for name in item.iter(&#39;author&#39;):\n            ary.append(name.text)\n\n        title_elements = item.findall(&#39;.\/\/dc:subject&#39;,namespaces) \n        for title_element in title_elements:\n            ary.append(title_element.text)\n\n        print(ary)\n\ncsv_file = open(&quot;.\/download.csv&quot;, &quot;r&quot;, encoding=&quot;utf_8&quot;, errors=&quot;&quot;, newline=&quot;&quot; )\n#csv \u8aad\u307f\u8fbc\u307f\nf = csv.reader(csv_file, delimiter=&quot;,&quot;, doublequote=True, lineterminator=&quot;\\r\\n&quot;, quotechar=&#39;&quot;&#39;, skipinitialspace=True)\n\n# Main\nfor i,row in enumerate(f):\n\n    print(&quot;Row:&quot; + str(i))\n    searchNDC(row[1],row[2])<\/code><\/pre><\/div>\n\n\n\n<p><strong>\u52d5\u4f5c\u78ba\u8a8d<\/strong><\/p>\n\n\n\n<p>\u4f7f\u7528\u3059\u308b\u305f\u3081\u306b\u306f\u3001\u5225\u9014Kindle\u306e\u8535\u66f8\u4e00\u89a7\u3092\u62bd\u51fa\u3057\u305fCSV\u30d5\u30a1\u30a4\u30eb\u304c\u5fc5\u8981\u3068\u306a\u308b\u3002\u62bd\u51fa\u65b9\u6cd5\u306b\u3064\u3044\u3066\u306f\u3001<a href=\"https:\/\/ubun2m.com\/?p=272\">\u4ee5\u524d\u306e\u8a18\u4e8b<\/a>\u3067\u7d39\u4ecb\u3057\u3066\u3044\u308b\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"158\" src=\"https:\/\/ubun2m.com\/wp-content\/uploads\/2022\/03\/Screenshot-2022-03-05-at-08.31.51-1024x158.png\" alt=\"\" class=\"wp-image-286\" srcset=\"https:\/\/ubun2m.com\/wp-content\/uploads\/2022\/03\/Screenshot-2022-03-05-at-08.31.51-1024x158.png 1024w, https:\/\/ubun2m.com\/wp-content\/uploads\/2022\/03\/Screenshot-2022-03-05-at-08.31.51-300x46.png 300w, https:\/\/ubun2m.com\/wp-content\/uploads\/2022\/03\/Screenshot-2022-03-05-at-08.31.51-768x118.png 768w, https:\/\/ubun2m.com\/wp-content\/uploads\/2022\/03\/Screenshot-2022-03-05-at-08.31.51-1536x236.png 1536w, https:\/\/ubun2m.com\/wp-content\/uploads\/2022\/03\/Screenshot-2022-03-05-at-08.31.51.png 1832w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">\u62bd\u51fa\u3057\u305fCSV\u306e\u4e00\u90e8(download.csv)<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"444\" src=\"https:\/\/ubun2m.com\/wp-content\/uploads\/2022\/03\/Screenshot-2022-03-05-at-08.39.34-1024x444.jpg\" alt=\"\" class=\"wp-image-287\" srcset=\"https:\/\/ubun2m.com\/wp-content\/uploads\/2022\/03\/Screenshot-2022-03-05-at-08.39.34-1024x444.jpg 1024w, https:\/\/ubun2m.com\/wp-content\/uploads\/2022\/03\/Screenshot-2022-03-05-at-08.39.34-300x130.jpg 300w, https:\/\/ubun2m.com\/wp-content\/uploads\/2022\/03\/Screenshot-2022-03-05-at-08.39.34-768x333.jpg 768w, https:\/\/ubun2m.com\/wp-content\/uploads\/2022\/03\/Screenshot-2022-03-05-at-08.39.34-1536x666.jpg 1536w, https:\/\/ubun2m.com\/wp-content\/uploads\/2022\/03\/Screenshot-2022-03-05-at-08.39.34.jpg 1920w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">python_serchNDC\u306e\u5b9f\u884c\u7d50\u679c<\/figcaption><\/figure>\n\n\n\n<p>\u30bf\u30a4\u30c8\u30eb\u306b\u300c\u5408\u672c\u7248\u300d\u3084\u300c\u65b0\u88c5\u7248\u300d\u306a\u3069\u3068\u5165\u3063\u3066\u3044\u308b\u672c\u306b\u3064\u3044\u3066\u306f\u691c\u7d22\u7d50\u679c\u304c\uff10\u3068\u306a\u3063\u3066\u3044\u308b\u3002\u3053\u308c\u3089\u3092\u53d6\u308a\u9664\u304f\u51e6\u7406\u3092\u5165\u308c\u308b\u3068\u691c\u7d22\u3067\u304d\u308b\u306e\u3060\u304c\u3001\u30d0\u30ea\u30a8\u30fc\u30b7\u30e7\u30f3\u304c\u591a\u3044\u306e\u3067\u3001\u3068\u308a\u3042\u3048\u305a\u5fc5\u8981\u3068\u601d\u308f\u308c\u308b\u51e6\u7406\u3060\u3051\u5165\u308c\u305f\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1004\" height=\"783\" src=\"https:\/\/ubun2m.com\/wp-content\/uploads\/2022\/03\/4101C908-9D83-4337-ABAB-6054846839C6_1_105_c.jpeg\" alt=\"\" class=\"wp-image-329\" srcset=\"https:\/\/ubun2m.com\/wp-content\/uploads\/2022\/03\/4101C908-9D83-4337-ABAB-6054846839C6_1_105_c.jpeg 1004w, https:\/\/ubun2m.com\/wp-content\/uploads\/2022\/03\/4101C908-9D83-4337-ABAB-6054846839C6_1_105_c-300x234.jpeg 300w, https:\/\/ubun2m.com\/wp-content\/uploads\/2022\/03\/4101C908-9D83-4337-ABAB-6054846839C6_1_105_c-768x599.jpeg 768w\" sizes=\"(max-width: 1004px) 100vw, 1004px\" \/><figcaption class=\"wp-element-caption\">\u8535\u66f8\u6574\u7406\u3057\u305f\u7d50\u679c\u3002\uff08\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3078\u306e\u8ffd\u52a0\u306f\u624b\u52d5\uff09<\/figcaption><\/figure>\n\n\n\n<p><strong>\u554f\u984c\u70b9<\/strong><\/p>\n\n\n\n<p>\u30fb\u691c\u7d22\u7d50\u679c\u304c\u8907\u6570\u3042\u308b\u5834\u5408\u3001\u3069\u306eNDC\u3092\u4f7f\u3046\u304b\u500b\u5225\u306b\u78ba\u8a8d\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002<br>\u30fbKindle\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306b\u8ffd\u52a0\u3059\u308b\u4f5c\u696d\u306f\u624b\u4f5c\u696d\u3002\uff08\u304b\u306a\u308a\u9762\u5012\u304f\u3055\u3044\uff09<br>    \u2192 API\u306f\u306a\u3055\u305d\u3046\u306a\u306e\u3067\u3001\u753b\u50cf\u8a8d\u8b58\u3092\u5229\u7528\u3057\u3066\u81ea\u52d5\u5316\u3059\u308b\u4e88\u5b9a\u3002<\/p>\n\n\n\n<p><strong>\u53c2\u8003HP<\/strong><\/p>\n\n\n\n<p>\u6771\u4eac\u90fd\u7acb\u56f3\u66f8\u9928 - NDC\u3063\u3066\u4f55\uff1f<br><a href=\"https:\/\/www.library.metro.tokyo.lg.jp\/support_school\/research\/for_study\/report_guide\/tool\/ndc\/\n\">https:\/\/www.library.metro.tokyo.lg.jp\/support_school\/research\/for_study\/report_guide\/tool\/ndc\/<br><\/a><br>\u56fd\u7acb\u56fd\u4f1a\u56f3\u66f8\u9928\u30b5\u30fc\u30c1 - API\u306e\u3054\u5229\u7528\u306b\u3064\u3044\u3066<br><a href=\"https:\/\/iss.ndl.go.jp\/information\/api\/\">https:\/\/iss.ndl.go.jp\/information\/api\/<\/a><\/p>\n\n\n\n<p>\u56fd\u7acb\u56fd\u4f1a\u56f3\u66f8\u9928\u30b5\u30fc\u30c1 - \u30a4\u30f3\u30bf\u30d5\u30a7\u30fc\u30b9\u4ed5\u69d8\u66f8\uff08\u7b2c2.1\u7248\uff09<br><a href=\"https:\/\/iss.ndl.go.jp\/information\/wp-content\/uploads\/2021\/03\/ndlsearch_api_20210329_jp.pdf\">https:\/\/iss.ndl.go.jp\/information\/wp-content\/uploads\/2021\/03\/ndlsearch_api_20210329_jp.pdf<\/a><\/p>\n\n\n\n<div class=\"affiliate-box\"><div class=\"affiliate-containar\"><a href=\"https:\/\/amzn.to\/3JXNQW4\" rel=\"nofollow\"><img decoding=\"async\" style=\"border: none;\" src=\"https:\/\/m.media-amazon.com\/images\/I\/71ckMQ8XgBL._AC_SX679_.jpg\" target=\"_blank\"><\/a><div class=\"affiliate-content\"><a href=\"https:\/\/amzn.to\/3JXNQW4\" rel=\"nofollow\">Kindle Paperwhite (8GB)<\/a><ul class=\"affiliate-button\"><li><a href=\"https:\/\/amzn.to\/3JXNQW4\" rel=\"nofollow\">Amazon<\/a><\/li><\/ul><\/div><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u65e5\u672c\u5341\u9032\u5206\u985e\u6cd5\uff08NDC\uff09\u3067Kindle\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3092\u6574\u7406\u3059\u308b\u305f\u3081\u306e\u88dc\u52a9\u30c4\u30fc\u30eb\u3092\u4f5c\u3063\u305f\u3002python3\u3067\u52d5\u4f5c\u78ba\u8a8d\u3002 \u52d5\u4f5c\u78ba\u8a8d \u4f7f\u7528\u3059\u308b\u305f\u3081\u306b\u306f\u3001\u5225\u9014Kindle\u306e\u8535\u66f8\u4e00\u89a7\u3092\u62bd\u51fa\u3057\u305fCSV\u30d5\u30a1\u30a4\u30eb\u304c\u5fc5\u8981\u3068\u306a\u308b\u3002\u62bd\u51fa\u65b9\u6cd5\u306b\u3064 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":708,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-283","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-3"],"acf":[],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/ubun2m.com\/wp-content\/uploads\/2022\/06\/4101C908-9D83-4337-ABAB-6054846839C6_1_105_c.webp","_links":{"self":[{"href":"https:\/\/ubun2m.com\/index.php?rest_route=\/wp\/v2\/posts\/283","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubun2m.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubun2m.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubun2m.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubun2m.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=283"}],"version-history":[{"count":0,"href":"https:\/\/ubun2m.com\/index.php?rest_route=\/wp\/v2\/posts\/283\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubun2m.com\/index.php?rest_route=\/wp\/v2\/media\/708"}],"wp:attachment":[{"href":"https:\/\/ubun2m.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=283"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubun2m.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=283"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubun2m.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=283"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}