• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 332
  • Last Modified:

How to fetch a URL in ASP

Hello,

This question refers to ASP, not to ASP.NET.

Given a URL, I need to download a page and put it's body into a variable.

This needs to happen at the server-side.  Because of the nature of my application, to download this in javascript or browser-side vb is unacceptable.  It must be downloaded by the server, and not by the web browser.


Thank you,
Nick
0
NickJohnson
Asked:
NickJohnson
  • 2
  • 2
1 Solution
 
peterxlaneCommented:
<%
strURL = "http://www.google.com"
Set oXML = Server.CreateObject("MSXML2.ServerXMLHTTP")

oXML.Open "GET", strURL, False
oXML.Send

If (oXML.readyState <> 4) Or (oXML.Status <> 200) Then
      oXML.Abort            
      strVariable = "ERROR"
Else
      strVariable = oXML.ResponseText
End If
Set oXML = Nothing

Response.Write strVariable
%>
0
 
NickJohnsonAuthor Commented:
Does this require the page's content to be valid xml?
0
 
NickJohnsonAuthor Commented:
Awesome; just checked it, it works.

Thanks,
Nick
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now