<form><inputname=ip/><inputtype=submitvalue="查询IP"></form> <% '来源:http://www.yongfa365.com IP = request("ip") If IP =""Then IP = request.servervariables("remote_addr") url ="http://www.ip.cn/ip.php?q="& IP &"" Body = getHTTPPage(url)
Set Re =New RegExp
Re.Pattern ="(查询结果:<br><br>[\s\S]+</font><br><br>)" Set Matches = Re.Execute(Body) If Matches.Count>0Then Body = Matches(0) Re.Pattern ="\[[\s\S]*\]" Body = Re.Replace(Body,"")
response.Write IP & Body %>
<% '函数区
Function getHTTPPage(Path) t = GetBody(Path) getHTTPPage = BytesToBstr(t,"GB2312") EndFunction
Function GetBody(url) OnErrorResumeNext Set Retrieval = CreateObject("Microsoft.XMLHTTP") With Retrieval .Open "Get", url,False,"","" .Send
GetBody =.ResponseBody EndWith Set Retrieval =Nothing
EndFunction
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
EndFunction %>