当前位置: 移动技术网 > IT编程>开发语言>Asp > ASP 获取腾讯IP地址的代码

ASP 获取腾讯IP地址的代码

2017年12月08日  | 移动技术网IT编程  | 我要评论
提问:
复制代码 代码如下:

<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),"市","")
%>

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网