Grab HTML with XML

This function shows you how to use XMLHTTP object to retrieve the HTML code of any webpage on the Internet.

The Code:

<%
 Function GetHTML(strPage)
     On Error Resume Next
     Set objXMLHttp = Server.CreateObject ("Microsoft.XMLHTTP")
     objXMLHttp.Open "GET", strPage ,False,"",""
     objXMLHttp.Send
     If Err.Number = 0 Then
         If objXMLHttp.Status = 200 then
             GetHTML = objXMLHttp.ResponseText
         Else
             GetHTML = "Incorrect URL"
         End if
     Else
         GetHTML = Err.Description
     End If
     Set objXMLHttp = Nothing 
End Function
%>

Usage: <%=GetHTML("http://www.yahoo.com")%>

Result


Yahoo | Mail, Weather, Search, Politics, News, Finance, Sports & Videos
Advertisement
Advertisement
Advertisement
00
day streak
Don't ghost us now.



html xml objXMLHttp xml objects


Back To Top
© 1998 - 2025 psacake.com
Version 8.13 | Advertise on this site