Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for nswhois.vbs

(view source code of nswhois.vbs as plain text)

  1. Option Explicit
  2.  
  3. WScript.Echo NetSolWhoIs( "google.com", 10 )
  4.  
  5.  
  6. Function NetSolWhoIs( myDomain, myTimeOut )
  7. ' This function uses Network Solutions, Inc.'s WhoIs page to
  8. ' retrieve information for .com, .org, and .net (and other)
  9. ' domains.
  10. ' Note that this function will break as soon as Network
  11. ' Solution alters the layout of the WhoIs results page.
  12. '
  13. ' Arguments:
  14. ' myDomain   [string]   domain name to be queried,
  15. '                       e.g. "google.com"
  16. ' myTimeOut  [integer]  time-out in seconds
  17. '
  18. ' Returns:
  19. ' Formated WhoIs information (multi-line string)
  20. '
  21. ' Written by Rob van der Woude
  22. ' http://www.robvanderwoude.com
  23.  
  24. 	Dim arrLine, arrText, blnTimedOut, i, objIE
  25.  
  26. 	' Open the appropriate NetSol WhoIs URL in Internet Explorer
  27. 	Set objIE = CreateObject( "InternetExplorer.Application" )
  28. 	objIE.Visible = False
  29. 	objIE.Navigate2 "https://www.networksolutions.com/whois/" _
  30. 	              & "registry-data.jsp?domain=" & Trim( myDomain )
  31.  
  32. 	' Wait till IE is ready
  33. 	i = 0
  34. 	blnTimedOut = False
  35. 	Do While objIE.Busy
  36. 		WScript.Sleep 100
  37. 		i = i + 1
  38. 		' Time out after the specified number of seconds
  39. 		If i > CInt( myTimeOut * 10 ) Then
  40. 			blnTimedOut = True
  41. 			Exit Do
  42. 		End If
  43. 	Loop
  44.  
  45. 	' Retrieve the URL's text and save it in an array
  46. 	If Not blnTimedOut Then
  47. 		arrText = Split( objIE.Document.Body.InnerText, vbLf )
  48. 	End If
  49.  
  50. 	' Close the Internet Explorer session
  51. 	objIE.Quit
  52. 	Set objIE = Nothing
  53.  
  54. 	' Check if a time-out occurred, and return the result
  55. 	If blnTimedOut Then
  56. 		NetSolWhoIs = "-- timed out --"
  57. 	Else
  58. 		' Filter out the lines starting with 3 spaces
  59. 		For i = 0 To UBound( arrText )
  60. 			If Left( arrText(i), 3 ) = "   " Then
  61. 				arrLine = Split( arrText(i), ":" )
  62. 				' Add the line to the function's return value
  63. 				NetSolWhoIs = NetSolWhoIs _
  64. 				            & Left( Trim( arrLine(0) ) _
  65. 				            & String( 20, " " ), 20 ) _
  66. 				            & arrLine(1) & vbCrLf
  67. 			End If
  68. 		Next
  69. 	End If
  70. End Function
  71.  

page last modified: 2024-04-16; loaded in 0.0050 seconds