GetHTTP with (excel) VBA?

I am looking for a query for an Excel VBA macro to get the HTML of a webpage as a string. I found some source with getHTTPrequest, but I can not register .net framwork system.dll or link it.

is there any friendly snippet? ;-) Thanks!

+7
source share
2 answers

Close enough: How can I send an HTTP POST request to a server from Excel using VBA? - This is even for Excel; -)

Just use the GET request instead:

objHTTP.Open "GET", URL, False

MSDN: Using a WinHttpRequest COM Object - Retrieving Data Using Visual Basic

+8
source

, URL, , HTTP - JSON API.


:

( )

Public Function getHTTP(ByVal url As String) As String
  With CreateObject("MSXML2.XMLHTTP")
    .Open "GET", url, False: .Send
    getHTTP = StrConv(.responseBody, vbUnicode)
  End With
End Function

:

(, ), :

  1. XML:

    Tools & rarr; References & rarr; 🗹 Microsoft XML, v6.0 ( , )

  2. : ( )

    Dim msXML As XMLHTTP60

  3. XML, :

    Public Function getHTTP(ByVal url As String) As String
      If msXML Is Nothing Then Set msXML = New XMLHTTP60
      With msXML
        .Open "GET", url, False: .Send
        getHTTP = StrConv(.responseBody, vbUnicode)
      End With
    End Function
    

: (for either method)

HTML :

Debug.Print getHTTP("https://stackoverflow.com/q/817602")
+1

All Articles