这篇文章给大家分享的是有关如何使用vbs查询IP地理位置的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。
msg="请输入你要查询的IP或域名:"
IP=Inputbox(msg,"IP地理位置查询小偷")
If IP = "" Then IP = "127.0.0.1"
url = "http://www.ip.cn/?q="& IP &""
Body = getHTTPPage(url)
Set Re = New RegExp
Re.Pattern = "(查询结果为:.+)"
Set Matches = Re.Execute(Body)
If Matches.Count>0 Then Body = Matches(0)
'Re.Pattern = "\[[\s\S]*\]"
'Body = Re.Replace(Body, "")
'wscript.echo IP & Body
Set oXMLHttpRequest=Nothing
Set objExplorer = WScript.CreateObject("InternetExplorer.Application")
objExplorer.Navigate "about:blank"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Visible = 1
objExplorer.height=300
objExplorer.width=400
objExplorer.left=400
objExplorer.resizable=0
objExplorer.Document.Body.InnerHTML =IP & Body
'objExplorer.document.parentwindow.clipboardData.SetData "text", IP & Body
Set objExplorer=nothing
'函数区
Function getHTTPPage(Path)
t = GetBody(Path)
getHTTPPage = BytesToBstr(t, "UTF-8")
End Function
Function GetBody(url)
On Error Resume Next
Set Retrieval = CreateObject("Microsoft.XMLHTTP")
With Retrieval
.Open "Get", url, False, "", ""
.Send
GetBody = .ResponseBody
End With
Set Retrieval = Nothing
End Function
Function BytesToBstr(Body, Cset)
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 = Cset
BytesToBstr = objstream.ReadText
objstream.Close
Set objstream = Nothing
End Function
感谢各位的阅读!关于“如何使用vbs查询IP地理位置”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。