+ Reply to Thread
Results 1 to 2 of 2

Thread: Getting Geographical Information

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    13

    Getting Geographical Information

    Hi , i want to display the Geographical Information like location using vbs , my input will be like : google.com and it should generate the ip and Geographical location .

  2. #2
    Junior Member
    Join Date
    Jan 2012
    Posts
    28
    First Step : [Add this function] :
    Code:
    Function GeoIP( myHost )
    
         Dim objGeoIP, objDNS, objRE, strDNS, strHost, strIP
    
         Set objDNS   = CreateObject( "SScripting.IPNetwork" )
         Set objGeoIP = CreateObject( "GeoIPCOMEx.GeoIPEx" )
         Set objRE    = New RegExp
    
         ' Resolve the specified host name or IP address
         strDNS = objDNS.DNSLookup( myHost )
    
         ' Check if the argument is a host name or an IP address
         objRE.Pattern = "ˆ[1-9][0-9]{0,2}(\.[0-9]{1,2}){3}$"
         If objRE.Test( myHost ) Then
             strIP   = myHost
             strHost = strDNS
         Else
             strIP   = strDNS
             strHost = myHost
         End If
    
         With objGeoIP
             ' Modify the path if you installed the GeoIP* database elsewhere
             .set_db_path "C:\Program Files\GeoIP\"
             .find_by_addr strIP
             GeoIP = Array( strHost, strIP, .city, .country_name, .country_code )
         End With
    
         Set objDNS   = Nothing
         Set objGeoIP = Nothing
         Set objRE    = Nothing
     End Function
    Second Step : [Add Example] :
    Code:
    Option Explicit
     WScript.Echo Join( GeoIP( "www.google.com" ), ", " )
     WScript.Echo Join( GeoIP( "208.67.219.101" ), ", " )
    Finally you should get :
    Code:
     www.google.com, 209.85.148.104, Seattle, United States, US
     www.opendns.com, 208.67.219.101, San Francisco, United States, US

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts