ASP uses ASP to store the code for obtaining Tencent's IP address, and the data read from it. Question:
Copy the code code as follows:
<script type=text/javascript src=http://fw.qq.com/ipaddress></script>
<script type=text/javascript>
var hehe1=IPData[2]
var hehe2=IPData[3]
alert(hehe1);
alert(hehe2);
document.write(IPData.join(' '));
</script>
How to use ASP to store the data read from above.
answer:
Copy the code code as follows:
<%
function GetResStr(URL,code)
err.clear
dimHttp,ReturnStr
Set Http=server.createobject(Microsoft.XMLHTTP)
Http.open GET,URL,False
Http.Send()
If Http.Readystate =4 Then
If Http.status=200 Then
ReturnStr=BytesToBstr(http.responseBody,code)
GetResStr=ReturnStr
End If
End If
End Function
'Function name:BytesToBstr
'Function: Convert binary data to characters
'Parameters: Body-binary data, Cset-text encoding method
Function BytesToBstr(Body,Cset)
Dim Objstream
Set Objstream = Server.CreateObject(adodb.stream)
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset =Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
dim vUrl,TempStr
vUrl=http://fw.qq.com/ipaddress
TempStr=GetResStr(vUrl,gb2312)
response.write Your IP is (asp gets the real IP):&split(TempStr,)(1) &split(TempStr,)(5) &replace(split(TempStr,)(7),city,)
%>