views:

248

answers:

2

Hi,

Using VBScript with ASP I am trying to set up an HTTP GET Request which will visit a page which in turn generates a line of ASCII (non-HTML). I then want to extrapolate that ASCII line which will have 4 values delimited by semicolons back into 4 variables in my original ASP page so that I can take those values and do something with them.

This is the page I want to access with HTTP GET Request http://www.certigo.com/demo/request.asp. Three of the values are null here.

I don't know much/anything about ASP, so I have this:

Dim oXMLHTTP

Dim strStatusTest

Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.3.0")

oXMLHTTP.Open "GET", "http://www.certigo.com/demo/request.asp", False

oXMLHTTP.Send

If oXMLHTTP.Status = 200 Then

strStatusText = oXMLHTTP.responseBody

End If

but obviously I haven't a clue what I'm doing because this isn't working at all. I would be totally unsurprised to learn that what I have here isn't going in the right direction. Please help!!

-Tracy

A: 

Try changing the oXMLHTTP.responseBody to oXMLHTTP.responseText and see if that works.

Refer to this web page if you need some more information on this technique:

http://classicasp.aspfaq.com/general/how-do-i-read-the-contents-of-a-remote-web-page.html.

Cammy Wan Kenobi
+3  A: 

Your code should look like this:-

Function GetTextFromUrl(url)

  Dim oXMLHTTP
  Dim strStatusTest

  Set oXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP.3.0")

  oXMLHTTP.Open "GET", url, False
  oXMLHTTP.Send

  If oXMLHTTP.Status = 200 Then

    GetTextFromUrl = oXMLHTTP.responseText

  End If

End Function

Dim sResult : sResult = GetTextFromUrl("http://www.certigo.com/demo/request.asp")

Note use ServerXMLHTTP from within ASP, the XMLHTTP component is designed for client side usage and isn't safe to use in the multithreaded environment such as ASP.

AnthonyWJones
Thank you, that helped so much! I got the rest of it working too. I really appreciate your help!
Tracy