Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use vbs to query IP Geographic location

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report