程序代码:
<% Function leleToStr(str) Dim stream Set stream=Server.CreateObject("ADODB.Stream") With stream .Type=1 .Mode=3 .Open .Write str .Position = 0 .Type = 2 .Charset = "gb2312" leleToStr = .ReadText .Close End With Set stream=Nothing End Function '获取IP所在地区 Function getIPAddress(ip) on error resume next dim xmlhttp,url,PostData PostData="searchip1="&ip url = "http://ip." set xmlhttp = server.CreateObject("Msxml2.XMLHTTP") xmlhttp.open "post",url,false xmlhttp.send(PostData) '开始截取字符 dim StartStr,EndStr,html html = leleToStr(xmlhttp.responseBody) StartStr = Instr(html,"所在地为:") EndStr = Instr(html,"如果该IP") html = mid(html,StartStr,EndStr-StartStr) '再次获取 StartStr = Instr(html,"<span>") StartStr = StartStr + 6 EndStr = Instr(html,"</span>") html = mid(html,StartStr,EndStr-StartStr) getIPAddress = html if err then err.clear:html = "" set xmlhttp = nothing End Function Response.Write(getIPAddress("114.95.39.80")) response.end %>
QQ:63572063