크롤링_crawling

winhttp 크롤링 vba 기본 code

VBA 2023. 4. 3. 23:47

첫번째 방법

 

Sub 검색()
    'winhttp5.1 참조 안함


    Set WinHttp = CreateObject("WinHttp.WinHttpRequest.5.1")
    Set doc = CreateObject("htmlfile")
        주소 = "주소입력"
        WinHttp.Open "GET", 주소, FALSE
        WinHttp.Send
        doc.body.innerhtml = WinHttp.ResponseText

 

.......

 

end sub

 

 

두번째 방법

Sub 모든종목가져오기()
    'winhttp 5.1 참조함
    Dim winhttp As New WinHttpRequest
    
      주소 = " 주소입력"
       winhttp.Open "GET", 주소
       winhttp.send
       결과 = winhttp.responseText

       Set json = JsonConverter.ParseJson(결과)  'jsonconverter 있어야함

 

  

......

 

end sub

 

 

 

 

--------------------

 

Function getDocument(text)
    Set getDocument = CreateObject("htmlfile")
    getDocument.body.innerHtml = text
End Function