exclusiveicon
New Member
- Joined
- Feb 9, 2015
- Messages
- 2
Can someone please advise me on how to accomplish this. I found some code that seems to be doing the job but when it stores the web source code it only stores about a quarter of the web source code.
how can I grab all the source code? The source code is about 301,000 characters (spaces included)
how can I grab all the source code? The source code is about 301,000 characters (spaces included)
Code:
Function GetPageSource(ByVal URL As String) As Variant
Dim msg As String
' Reset the Global variables.
PageSrc = ""
Set HTMLdoc = Nothing
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", URL, True
.Send
While .readyState <> 4: DoEvents: Wend
' Check for any server errors.
If .statusText <> "OK" Then
' Check for WinHTTP error.
msg = GetWinHttpErrorMsg(.Status)
If msg = "" Then msg = .statusText
' Return the error number and message.
GetPageSource = "ERROR: " & .Status & " - " & msg
Exit Function
End If
' Save the HTML code in the Global variable.
PageSrc = .responseText
End With
' Create an empty HTML Document.
Set HTMLdoc = CreateObject("htmlfile")
HTMLdoc.Open URL:="text/html", Replace:=False
' Convert the HTML code into an HTML Document Object.
HTMLdoc.write PageSrc
' Terminate Input-Output with the Global variable.
HTMLdoc.Close
' Return the HTML text of the web page.
GetPageSource = PageSrc
End Function