HTTP GET Request, ASP - I'm lost!

2019-01-12 06:08发布

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

2条回答
Melony?
2楼-- · 2019-01-12 06:38

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.

查看更多
【Aperson】
3楼-- · 2019-01-12 06:55

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.

查看更多
登录 后发表回答