{"id":2455,"date":"2022-11-08T22:54:35","date_gmt":"2022-11-08T13:54:35","guid":{"rendered":"http:\/\/oreoreki.gotdns.ch\/?p=2455"},"modified":"2022-11-08T22:54:35","modified_gmt":"2022-11-08T13:54:35","slug":"post-2455","status":"publish","type":"post","link":"http:\/\/oreoreki.gotdns.ch\/?p=2455","title":{"rendered":"Excel VBA\u3067Youtube\u306e\u30b5\u30e0\u30cd\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3010\u3086\u3063\u304f\u308a\u89e3\u8aac\u3011"},"content":{"rendered":"<p><span class=\"embed-youtube\" style=\"text-align:center; display: block;\"><iframe loading=\"lazy\" class=\"youtube-player\" width=\"750\" height=\"422\" src=\"https:\/\/www.youtube.com\/embed\/JwU_vre8XJQ?version=3&#038;rel=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;fs=1&#038;hl=ja&#038;autohide=2&#038;wmode=transparent\" allowfullscreen=\"true\" style=\"border:0;\" sandbox=\"allow-scripts allow-same-origin allow-popups allow-presentation allow-popups-to-escape-sandbox\"><\/iframe><\/span><\/p>\n<div class=\"hcb_wrap\">\n<p>Excel VBA\u3067Youtube\u306e\u30b5\u30e0\u30cd\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u306e\u4f5c\u6210\u3057\u3066\u307f\u305f<br \/>\n<span class=\"bold-red\">\u3053\u306e\u52d5\u753b\u306e\u30de\u30af\u30ed\u306fWindows11\/Office2016\u3067\u4f5c\u6210\u3057\u3066\u307e\u3059\u3002<br \/>\n<\/span><\/p>\n<h2><\/h2>\n<pre class=\"prism line-numbers lang-ts\" data-lang=\"TypeScript\"><code>Declare PtrSafe Sub Sleep Lib \"kernel32\" (ByVal dwMilliseconds As Long)\r\nDeclare PtrSafe Function URLDownloadToFile Lib \"urlmon\" Alias \"URLDownloadToFileA\" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long\r\n\r\nSub Macro()\r\n    Set fso = CreateObject(\"Scripting.FileSystemObject\")\r\n    CurrentDirectory = ThisWorkbook.Path\r\n    \r\n    download_dir = fso.BuildPath(CurrentDirectory, \"thumbnail\")\r\n    If (fso.FolderExists(download_dir) = True) Then\r\n\r\n        '\/\/ \u30d5\u30a9\u30eb\u30c0\u304c\u5b58\u5728\u3059\u308b\r\n        fso.DeleteFolder download_dir, True\r\n    End If\r\n    MkDir download_dir\r\n    \r\n    '\u30d6\u30e9\u30a6\u30b6\u3092\u8d77\u52d5\r\n    Dim driver As New Selenium.WebDriver\r\n    Set driver = CreateObject(\"Selenium.webDriver\")\r\n\r\n\r\n    driver.Start \"chrome\"\r\n    driver.ExecuteScript (\"Object.defineProperty(navigator, 'webdriver', {get: () => undefined})\")\r\n    \r\n    '\u7b2c2\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\u306b\u30d6\u30e9\u30a6\u30b6\u3092\u8868\u793a\r\n    driver.Window.SetSize 750, 900\r\n    driver.Window.SetPosition 2000, -700\r\n    \r\n    driver.Get \"https:\/\/www.youtube.com\/channel\/UC1I8CiC80NrTrqb0yGqKLQg\/videos\"\r\n    Call Sleep(2000)  '2\u79d2\u5f85\u3064\r\n    \r\n    Set o_elem = driver.FindElementsByCss(\"a#thumbnail\")\r\n    For i = 1 To o_elem.Count\r\n        a = Split(o_elem.Item(i).Attribute(\"href\"), \"=\")\r\n        If UBound(a) = 1 Then\r\n            'Debug.Print a(1)\r\n            ' http:\/\/img.youtube.com\/vi\/O-zqWNabYAc\/sddefault.jpg\r\n            th_url = \"http:\/\/img.youtube.com\/vi\/\" & a(1) & \"\/maxresdefault.jpg\"\r\n            res = URLDownloadToFile(0, th_url, fso.BuildPath(download_dir, a(1) & \".jpg\"), 0, 0)\r\n            \r\n        End If\r\n    Next\r\n\r\n    '\u30d6\u30e9\u30a6\u30b6\u3092\u9589\u3058\u308b\r\n    driver.Quit\r\n    Set driver = Nothing\r\nEnd Sub\r\n<\/code><\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Excel VBA\u3067Youtube\u306e\u30b5\u30e0\u30cd\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u306e\u4f5c\u6210\u3057\u3066\u307f\u305f \u3053\u306e\u52d5\u753b\u306e\u30de\u30af\u30ed\u306fWindo [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2457,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[34],"tags":[],"class_list":["post-2455","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vba"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"http:\/\/oreoreki.gotdns.ch\/wp-content\/uploads\/sites\/2\/2022\/11\/excel-vbayoutube.jpg","jetpack_shortlink":"https:\/\/wp.me\/p9WqRX-DB","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=\/wp\/v2\/posts\/2455","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2455"}],"version-history":[{"count":1,"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=\/wp\/v2\/posts\/2455\/revisions"}],"predecessor-version":[{"id":2456,"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=\/wp\/v2\/posts\/2455\/revisions\/2456"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=\/wp\/v2\/media\/2457"}],"wp:attachment":[{"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2455"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2455"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2455"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}