Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use vbs to query IP Geographic location

Shulou Source: shulou.com Published: 2022-06-03 06:02:25 10月01日 Update

This article is about how to use vbs to query the geographic location of IP. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Msg= "Please enter the IP or domain name you want to query:"

IP=Inputbox (msg, "IP Geographic location search Thieves")

If IP = "" Then IP = "127.0.0.1"

Url = "http://www.ip.cn/?q="& IP &"

Body = getHTTPPage (url)

Set Re = New RegExp

Re.Pattern = "(query result:. +)"

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

'Functional area

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

Thank you for reading! This is the end of this article on "how to use vbs to query IP geographic location". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Tags: Query location geography location content more articles good practical functions domain names thieves articles see knowledge results UTF-8 references help related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Microsoft Apple Redmi macOS