1. WinHttp.WinHttpRequest 객체를 이용한 방법
Sub WinHttp_WinHttpRequest()
Set Winhttp = CreateObject("WinHttp.WinHttpRequest.5.1")
Winhttp.Open "GET", "http://www.naver.com"
Winhttp.Send
html = Winhttp.ResponseText
MsgBox html
End Sub
2. InternetExplorer.Application 객체를 이용한 방법
Sub InternetExplorer_Application()
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Navigate "http://www.naver.com"
.Resizable = True
.MenuBar = False
.Toolbar = False
.AddressBar = False
.StatusBar = False
.Left = 0
.Top = 0
.Width = 1200
.Height = 800
.Visible = True
End With
'익스플로러 켜질 때까지 대기
Do While IE.Busy
DoEvents
Loop
'MsgBox IE.Document.head.innerhtml
MsgBox IE.Document.body.innerhtml
End Sub
2번은 익스플로러 버전과 속도에 제한을 받지만 1번은 그렇지 않다. 1번은 브라우저에서 자바스크립트가 꺼졌을때의 값을 가져오지만, 2번은 익스플로러에 의존한다.