萬盛學電腦網

 萬盛學電腦網 >> 網絡編程 >> asp編程 >> ASP 獲取騰訊IP地址的接口程序代碼

ASP 獲取騰訊IP地址的接口程序代碼

<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>

如何用ASP來存儲,從上面讀取出來的數據呢。
回答:
復制代碼 代碼如下:
<%
function GetResStr(URL,code)
err.clear
dim Http,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
'函數名:BytesToBstr
'作用:轉換二進制數據為字符
'參數:Body-二進制數據,Cset-文本編碼方式
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 "您的IP為(asp教程獲取真實IP):"&split(TempStr,"""")(1)" " &split(TempStr,"""")(5)" "&replace(split(TempStr,"""")(7),"市","")
%>

ASP 獲取騰訊IP地址的接口程序代碼

copyright © 萬盛學電腦網 all rights reserved