提问:
复制代码 代码如下:
<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),"市","")
%>
申明:本教程内容由威凡网编辑整理并提供IT程序员分享学习,如文中有侵权行为,请与站长联系(QQ:254677821)!