<%
\' *** Get a file through HTTP ( GetHttp(\"
www.azero.dk/forside.asp\") )
Function GetHttp(strUrl)
\' Reserve variables
Dim strHost
\' Start error handling
On Error Resume Next
\' Strip off http://
If LCase(Left(strUrl, 7)) = \"
http://\" Then
strUrl = Right(strUrl, Len(strUrl) - 7)
End If
\' Split server address and filename
If InStr(strUrl, \"/\") > 0 Then
strHost = Left(strUrl, InStr(strUrl, \"/\") - 1 )
strUrl = Right(strUrl, (Len(strUrl) - InStr(strUrl, \"/\")) + 1 )
End If
\' Add port if not included
If InStr(strHost, \":\") = 0 Then
strHost = strHost & \":80\"
End If
\' Create object
set Socket = server.CreateObject(\"Socket.TCP\")
\' Set hostadress
socket.Host = strHost
\' Set timeout to 5 seconds
Socket.TimeOut = 5000
\' Open connection to host
Socket.Open
\' Send getline for content
Socket.SendLine(\"GET /\" & strUrl & \" HTTP/1.0\" & Chr(13) & Chr(10) & \"Host: \" & strHost & Chr(13) & Chr(10))
\' Wait until content is recieved
Socket.WaitForDisconnect()
\' Insert data into function
GetHttp = Socket.Buffer
\' Close object
Socket.Close()
\' Error
If Err.Number <> 0 Then
Response.Write Err& \": \" & Err.Description
Response.Write \"<br>Host:[\" & strHost & \"]<br>Url:[\" & strUrl & \"]\"
Exit function
End If
On Error Goto 0
End Function
\' *** Get content within a tag (strS) ( GetHttpData(\"
www.azero.dk/forside.asp\", \"body\") )
Function GetHttpData(strUrl,strS)
Dim strT
strT = GetHttp(strUrl)
strT = Mid(strT, InStr(LCase(strT), \"<\" & LCase(strS)))
strT = Mid(strT, InStr(LCase(strT), \">\") + 1)
strT = Left(strT, InStrRev(LCase(strT), \"</\" & LCase(strS)) - 1)
GetHttpData = strT
End Function
\' *** Get the header from a file through HTTP ( GetHttpHeader(\"
www.azero.dk/forside.asp\") )
Function GetHttpHeader(strUrl)
Dim strT
strT = GetHttp(strUrl)
strT = Mid(strT, 1, InStr(strT, Chr(13) & Chr(10) & Chr(13) & Chr(10)))
GetHttpHeader = strT
End Function
\' *** Get the body from a file through HTTP ( GetHttpBody(\"
www.azero.dk/forside.asp\") )
Function GetHttpBody(strUrl)
Dim strT
strT = GetHttp(strUrl)
strT = Mid(strT, InStr(strT, Chr(13) & Chr(10) & Chr(13) & Chr(10)) + 4)
GetHttpBody = strT
End Function
\' Hent alt mellem <body> og </body> fra vores bestillingsside og udskriv det
Response.Write GetHttpData(\"azero.dk/bestil/default.asp\", \"body\")
%>
Hentet fra
www.azero.dk ´s supportside.