Rob van der Woude's Scripting Pages

VBScript Scripting Techniques > Network > WhoIs

Query WhoIs Database

  1. InternetExplorer.Application (Function)
  2. InternetExplorer.Application (Class)
  3. InternetExplorer.Application (WSC)

 

InternetExplorer.Application (Function)
VBScript Code:
Option Explicit

WScript.Echo NetSolWhoIs( "google.com", 10 )


Function NetSolWhoIs( myDomain, myTimeOut )
' This function uses Network Solutions, Inc.'s WhoIs page to
' retrieve information for .com, .org, and .net (and other)
' domains.
' Note that this function will break as soon as Network
' Solution alters the layout of the WhoIs results page.
'
' Arguments:
' myDomain   [string]   domain name to be queried,
'                       e.g. "google.com"
' myTimeOut  [integer]  time-out in seconds
'
' Returns:
' Formatted WhoIs information (multi-line string)
'
' Written by Rob van der Woude
' http://www.robvanderwoude.com

    Dim arrLine, arrText, blnTimedOut, i, objIE

    ' Open the appropriate NetSol WhoIs URL in Internet Explorer
    Set objIE = CreateObject( "InternetExplorer.Application" )
    objIE.Visible = False
    objIE.Navigate2 "https://www.networksolutions.com/whois/" _
                  & "registry-data.jsp?domain=" & Trim( myDomain )

    ' Wait till IE is ready
    i = 0
    blnTimedOut = False
    Do While objIE.Busy
        WScript.Sleep 100
        i = i + 1
        ' Time out after the specified number of seconds
        If i > CInt( myTimeOut * 10 ) Then
            blnTimedOut = True
            Exit Do
        End If
    Loop

    ' Retrieve the URL's text and save it in an array
    If Not blnTimedOut Then
        arrText = Split( objIE.Document.Body.InnerText, vbLf )
    End If

    ' Close the Internet Explorer session
    objIE.Quit
    Set objIE = Nothing

    ' Check if a time-out occurred, and return the result
    If blnTimedOut Then
        NetSolWhoIs = "-- timed out --"
    Else
        ' Filter out the lines starting with 3 spaces
        For i = 0 To UBound( arrText )
            If Left( arrText(i), 3 ) = "   " Then
                arrLine = Split( arrText(i), ":" )
                ' Add the line to the function's return value
                NetSolWhoIs = NetSolWhoIs _
                            & Left( Trim( arrLine(0) ) _
                            & String( 20, " " ), 20 ) _
                            & arrLine(1)
                If UBound( arrLine ) = 2 Then
                    NetSolWhoIs = NetSolWhoIs _
                                & ":" & arrLine(2)
                End If
                NetSolWhoIs = NetSolWhoIs & vbCrLf
            End If
        Next
    End If
End Function
Sample Output:
Domain Name          GOOGLE.COM
Registrar            MARKMONITOR, INC.
Whois Server         whois.markmonitor.com
Referral URL         http://www.markmonitor.com
Name Server          NS1.GOOGLE.COM
Name Server          NS2.GOOGLE.COM
Name Server          NS3.GOOGLE.COM
Name Server          NS4.GOOGLE.COM
Status               clientDeleteProhibited
Status               clientTransferProhibited
Status               clientUpdateProhibited
Updated Date         10-apr-2006
Creation Date        15-sep-1997
Expiration Date      14-sep-2011
 
Requirements:
Windows version: any
Network: any (Internet connection)
Client software: Internet Explorer 4 or later
Script Engine: WSH
Summarized: Works in all Windows versions with Internet Explorer 4 or later, and an Internet connection.
Needs to be modified (replace WScript.Sleep) to work in HTAs.
 
[Back to the top of this page]

page last uploaded: 2016-09-19, 14:58