{"id":1126,"date":"2020-08-24T23:22:02","date_gmt":"2020-08-24T14:22:02","guid":{"rendered":"https:\/\/dalomo.net\/blog\/?p=1126"},"modified":"2020-09-12T13:59:52","modified_gmt":"2020-09-12T04:59:52","slug":"%e3%83%87%e3%83%bc%e3%82%bf%e3%83%99%e3%83%bc%e3%82%b9%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%9f%e3%82%b5%e3%82%a4%e3%83%88%e3%82%92%e4%bd%9c%e3%82%8a%e3%81%9f%e3%81%84%e2%91%a0","status":"publish","type":"post","link":"https:\/\/dalomo.net\/blog\/2020\/08\/24\/1126\/","title":{"rendered":"\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u4f7f\u3063\u305f\u30b5\u30a4\u30c8\u3092\u4f5c\u308a\u305f\u3044\u2460 \u30c7\u30fc\u30bf\u3092\u53ce\u96c6\u3059\u308b"},"content":{"rendered":"<h1>\u3042\u3093\u307e\u8907\u96d1\u3058\u3083\u306a\u3044\u3084\u3064<\/h1>\n<p>\u306a\u3093\u304b\u3044\u3044\u984c\u6750\u306a\u3044\u304b\u306a\u30fc\u3068\u3001\u3055\u8ff7\u3063\u3066\u3044\u305f\u3089\u5c06\u68cb\u9023\u76df\u306e\u30b5\u30a4\u30c8\u306b\u307e\u3044\u306b\u3061\u8a70\u5c06\u68cb\u3068\u3044\u3046\u30b3\u30fc\u30ca\u30fc\u304c\u3042\u308b\u306e\u3092\u77e5\u3063\u305f\u3002<\/p>\n<p><a href=\"https:\/\/www.shogi.or.jp\/tsume_shogi\/everyday\/\">https:\/\/www.shogi.or.jp\/tsume_shogi\/everyday\/<\/a><\/p>\n<p>\u3053\u308c\u306e\u53f3\u306e\u30e1\u30cb\u30e5\u30fc\u306e\u3068\u3053\u308d\u306e\u624b\u6570\u306e\u30ea\u30f3\u30af\u306f\u3053\u306e\u307e\u3044\u306b\u3061\u8a70\u5c06\u68cb\u306e\u30ab\u30c6\u30b4\u30ea\u5206\u3051\u3055\u308c\u3066\u3044\u308b\u308f\u3051\u3067\u306f\u306a\u304f\u3001\u307e\u305f\u5225\u7269\u3067\u3001\u307e\u3044\u306b\u3061\u8a70\u5c06\u68cb\u81ea\u4f53\u306f\u7279\u306b\u6574\u7406\u3055\u308c\u3066\u3044\u308b\u308f\u3051\u3067\u306f\u306a\u3055\u6c17\u306a\u611f\u3058\u3060\u3063\u305f\u3002\u3053\u308c\u3092\u3044\u3044\u611f\u3058\u306b\u691c\u7d22\u3067\u304d\u308b\u30b5\u30a4\u30c8\u3068\u304b\u3069\u3046\u304b\u306a\u30fc\u3068\u601d\u3063\u305f\u306e\u3067\u6311\u6226\u3057\u3066\u307f\u308b\u3002<\/p>\n<h2>\u30b9\u30af\u30ec\u30a4\u30d4\u30f3\u30b0<\/h2>\n<p>\u3068\u308a\u3042\u3048\u305a\u4eca\u3042\u308b\u8a70\u5c06\u68cb\u3092\u96c6\u3081\u3066\u30c7\u30fc\u30bf\u3092\u4f5c\u308b\u3002\u4eca\u81ea\u5206\u306b\u3067\u304d\u308b\u306e\u306fVBA+IE\u3067\u306e\u30b9\u30af\u30ec\u30a4\u30d4\u30f3\u30b0\u306a\u306e\u3067\u3001\u305d\u308c\u4f7f\u3063\u3066\u30c7\u30fc\u30bf\u3092\u53ce\u96c6\u3059\u308b\u3002<\/p>\n<pre><code class=\"vba\">Sub getdata()\r\n\r\n    Dim objIE As InternetExplorer\r\n    Set objIE = CreateObject(\"Internetexplorer.Application\")\r\n    \r\n    objIE.Visible = True\r\n    objIE.navigate \"https:\/\/www.shogi.or.jp\/tsume_shogi\/everyday\/\"\r\n    \r\n    Do While objIE.Busy = True Or objIE.readyState &lt;&gt; 4\r\n    DoEvents\r\n    Loop\r\n    \r\n    Dim htmldoc As HTMLDocument\r\n    Set htmldoc = objIE.document\r\n    \r\n    Call scrape(htmldoc)\r\n    \r\n    Dim lastpg As Long\r\n    lastpg = 103\r\n    \r\n    For i = 2 To lastpg\r\n        objIE.navigate \"https:\/\/www.shogi.or.jp\/tsume_shogi\/everyday\/index_\" &amp; i &amp; \".html\"\r\n\r\n        Do While objIE.Busy = True Or objIE.readyState &lt;&gt; 4\r\n        DoEvents\r\n        Loop\r\n\r\n        Set htmldoc = objIE.document\r\n\r\n        Call scrape(htmldoc)\r\n\r\n    Next i\r\n\r\nEnd Sub\r\nFunction scrape(ByVal doc As HTMLDocument)\r\n    \r\n    \r\n    Dim ul As IHTMLElementCollection\r\n    Set ul = doc.getElementsByClassName(\"floatListA01Col3-30 indexListA01 fixHeight section04\")\r\n    \r\n    Dim taga As IHTMLElementCollection\r\n    Set taga = ul(0).getElementsByTagName(\"a\")\r\n    \r\n    Dim tagp As IHTMLElementCollection\r\n    Set tagp = ul(0).getElementsByTagName(\"p\")\r\n    \r\n    For i = 0 To 11\r\n        Dim lr As Long\r\n        lr = ThisWorkbook.Sheets(\"data\").Cells(Rows.Count, 1).End(xlUp).Row\r\n    \r\n        ThisWorkbook.Sheets(\"data\").Range(\"A\" &amp; lr + 1).Value = tagp(i).innerText\r\n        ThisWorkbook.Sheets(\"data\").Range(\"B\" &amp; lr + 1).Value = taga(i).href\r\n    Next i\r\n\r\nEnd Function<\/code><\/pre>\n<p>\u3053\u3093\u306a\u3002\u6700\u5f8c\u306e\u30da\u30fc\u30b8\u3067\u30a8\u30e9\u30fc\u51fa\u3066\u6b62\u307e\u308b\u3051\u3069\u3001\u3068\u308a\u3042\u3048\u305a\u76ee\u7684\u306e\u30c7\u30fc\u30bf\u3092\u96c6\u3081\u308c\u305f\u3002<\/p>\n<p><a href=\"https:\/\/docs.google.com\/spreadsheets\/d\/1Y4m1OsRpKM8bNnK9abkaHeeSyOuwnDy_jHKV79QnNW0\/edit?usp=sharing\">https:\/\/docs.google.com\/spreadsheets\/d\/1Y4m1OsRpKM8bNnK9abkaHeeSyOuwnDy_jHKV79QnNW0\/edit?usp=sharing<\/a><\/p>\n<p>\u3067\u3001\u3053\u308c\u3092\u3061\u3087\u3063\u3068\u52a0\u5de5\u3057\u3066\u3001\u4f5c\u6210\u8005\u3068\u624b\u6570\u306e\u5217\u3068\u66f4\u65b0\u65e5\u306e\u5217\u3092\u4f5c\u3063\u3066\u3001\u3093\u30fc\u3001\u3068\u308a\u3042\u3048\u305aCSV\u3067\u4fdd\u5b58\u3059\u308b\u3002<\/p>\n<p><a href=\"https:\/\/docs.google.com\/spreadsheets\/d\/16K37qfVCaHQOl1gGXy9PqUn_zjQm9U3n272CfIKKmvE\/edit?usp=sharing\">https:\/\/docs.google.com\/spreadsheets\/d\/16K37qfVCaHQOl1gGXy9PqUn_zjQm9U3n272CfIKKmvE\/edit?usp=sharing<\/a><\/p>\n<p>\u3053\u3093\u306a\u3002\u306a\u3093\u304b\u3001\u5225\u306b\u3082\u3046\u3053\u308c\u3067\u30d5\u30a3\u30eb\u30bf\u304b\u3051\u308a\u3083\u76ee\u7684\u9054\u6210\u3067\u304d\u3066\u306d\uff1f\u3063\u3066\u3044\u3046\u306e\u306f\u3042\u308b\u3082\u306e\u306e\u3001\u3053\u308c\u3092\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u4fdd\u5b58\u3057\u3066\u30fc\u3001\u30af\u30a8\u30ea\u306b\u5fdc\u3058\u3066\u30c7\u30fc\u30bf\u5f15\u3063\u5f35\u3063\u3066\u304d\u3066\u8868\u793a\u30fc\u307f\u305f\u3044\u306a\u306e\u3092\u3084\u308a\u305f\u3044\u306e\u3002<\/p>\n<p>\u3068\u308a\u3042\u3048\u305a\u4eca\u65e5\u306f\u3053\u3053\u307e\u3067\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3042\u3093\u307e\u8907\u96d1\u3058\u3083\u306a\u3044\u3084\u3064 \u306a\u3093\u304b\u3044\u3044\u984c\u6750\u306a\u3044\u304b\u306a\u30fc\u3068\u3001\u3055\u8ff7\u3063\u3066\u3044\u305f\u3089\u5c06\u68cb\u9023\u76df\u306e\u30b5\u30a4\u30c8\u306b\u307e\u3044\u306b\u3061\u8a70\u5c06\u68cb\u3068\u3044\u3046\u30b3\u30fc\u30ca\u30fc\u304c\u3042\u308b\u306e\u3092\u77e5\u3063\u305f\u3002 https:\/\/www.shogi.or.jp\/tsume_shogi\/everyday &hellip; <a href=\"https:\/\/dalomo.net\/blog\/2020\/08\/24\/1126\/\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[8],"tags":[121,125,120],"class_list":["post-1126","post","type-post","status-publish","format-standard","hentry","category-8","tag-vba","tag-125","tag-120"],"_links":{"self":[{"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/posts\/1126","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/comments?post=1126"}],"version-history":[{"count":2,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/posts\/1126\/revisions"}],"predecessor-version":[{"id":1135,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/posts\/1126\/revisions\/1135"}],"wp:attachment":[{"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/media?parent=1126"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/categories?post=1126"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/tags?post=1126"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}