0

I want to extract response body of a webpage. The information I need is in the response body of page 43 out of 60. I tried using another solution which gives me some Chinese texts from the response body (I guess it is encrypted).

I tried some code which gives me response text which is not a requirement here. You can check the response body of page in developer tools-->network-->details-->response body.

It loads only when you click on network traffic capturing button and then refresh the page. It will track all the requests and responses.

How do I get the Response body (not response text) from the webpage using VBA?

1
  • You should include what you have done so far (the code). Commented Mar 11, 2016 at 5:09

1 Answer 1

1

this is the code which gives me first response body but want to loop through all response bodies of a web page.

Sub HTMLsearch()
    Dim Html As String
    Html = GetHTML("https://portal.mylink.com/vspace/")

    ' Cyrillic characters are supported in Office, so they will appear correctly
    rsbody= Html
End Sub

Function GetHTML(Url As String) As String
    Dim request As Object
    Set request = CreateObject("Msxml2.XMLHTTP.3.0")
    Dim converter As New ADODB.stream

    ' fetch page
    request.Open "GET", Url, False
    request.send

    ' write raw bytes to the stream
    converter.Open
    converter.Type = adTypeBinary
    converter.Write request.ResponseBody

    ' read text characters from the stream
    converter.Position = 0
    converter.Type = adTypeText
    converter.Charset = "Windows-1251"

    ' set return value, close the stream
    GetHTML = converter.ReadText
    converter.Close
End Function
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.