Skip to content

Instantly share code, notes, and snippets.

Created Oct 19, 2019
What would you like to do?
Option Explicit
Private Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Main()
Dim ie As Object
Set ie = CreateObject("InternetExplorer.application")
ie.Visible = True
ie.navigate ""
While ie.busy Or ie.readyState <> 4
Sleep 1&
Dim win As MSHTML.IHTMLWindow5
Set win = ie.document.parentWindow
Dim tmp As HTMLXMLHttpRequestFactory
Set tmp = win.XMLHttpRequest
Dim XHR As Object 'HTMLXMLHttpRequestでなく、「XHR2」なので、IDispatchで受ける。
Set XHR = tmp.Create
Dim B() As Byte
With XHR
.Open "GET", "#" & Timer, False
.responseType = "ArrayBuffer"
B = .response
With CreateObject("ADODB.Stream")
.Type = 1
.write B
.SaveToFile CreateObject("WScript.Shell").SpecialFolders("Desktop") & "\hoge.html", 2
End With
End With
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment