日期:2014-05-16  浏览次数:20846 次

ASP 判断IP地址定位
我想通过IP地址,来定位访问者来源。
我知道可以通过一个IP文件或者数据库,通过访问IP地址段查询得到,这种方法有两个问题
一、ip地址文件要更新
二、IP地址文件太大,检测起来会影响服务器响应

我现在想通过访问网站的IP地址,到http://www.ip.cn/网站获取定位地址如何实现

我知道好像可以通过正则表达式来解决。。

不是很了解正则。。。特来请教高手。。。
希望回答的详细点

新人分不多。。请见谅
------解决方案--------------------
http://www.ip.cn/getip.php?action=queryip&ip_url=ip地址&from=web

这个是他们的查询接口,不过一天之内查询100次,如果访问量大就没什么意义了从这里捉去数据

Function GETHttpPage(GetUrl) 
  Dim xmlHttp 
  Dim RetStr    
  Set xmlHttp =server.CreateObject("Msxml2.XMLHTTP")   
  xmlHttp.Open "GET",GetUrl, False 
  xmlHttp.Send
  If Err.Number <> 0 Then 
    Set xmlHttp=Nothing 
    GETHttpPage = "ERROR"
    Exit Function 
  End If 
  GETHttpPage=bytesToBSTR(xmlHttp.responseBody,"GB2312") 
  Set xmlHttp= nothing 
End Function

Function  BytesToBstr(strBody,CodeBase) 
  dim obj 
  set obj=Server.CreateObject("Adodb.Stream") 
  obj.Type=1 
  obj.Mode=3 
  obj.Open 
  obj.Write strBody 
  obj.Position=0 
  obj.Type=2 
  obj.Charset=CodeBase 
  BytesToBstr=obj.ReadText 
  obj.Close 
  set obj=nothing 
End Function 
ip=request.ServerVariables("remote_addr")

response.Write "
------解决方案--------------------
"&GETHttpPage("http://www.ip.cn/getip.php?action=queryip&ip_url="&ip&"&from=web")&"
------解决方案--------------------
"