提問:
復制代碼 代碼如下:
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),"市","")
%>
您可能感興趣的文章:- 以IP來獲取客戶端電腦名稱(一句代碼實現)
- ASP.NET獲取真正的客戶端IP地址的6種方法
- 獲取客戶端電腦日期時間js代碼(jquery)
- IP138 IP地址查詢小偷實現代碼
- asp.net 通過指定IP地址得到當前的網絡上的主機的域名
- asp.net DZ論壇中根據IP地址取得所在地的代碼
- 獲取客戶端IP地址c#/vb.net各自實現代碼