Function getAddr(from_IP)
getAddr="未知地址"
if from_IP &"CS"<>"CS" then
dim objXML,getAddrTmp
set objXML=createobject("MSXML2.XMLHTTP")
objXML.open "post","https://www.ip138.com/iplookup.asp?action=2&ip="& from_IP,false
objXML.send()
If objXML.readystate<>4 then
exit function
End If
getAddrTmp=BytesToBstr(objXML.responseBody)
if instr(getAddrTmp,"本站數(shù)據(jù):")>0 and instr(getAddrTmp,"</li>")>0 then getAddr=left(split(split(getAddrTmp,"本站數(shù)據(jù):")(1),"</li>")(0),50)
set objXML=nothing
if err.number<>0 then err.Clear
end if
End Function
Function BytesToBstr(body)
dim objstream
set objstream = CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = "GB2312" '編碼方式
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
end Function
temp_ip="156.2.36.96"
response.write (getAddr(temp_ip))