Option Explicit Dim blnSaveToFile Dim intArgs Dim objADODB, objIE Dim strFile, strText, strURL Const ForAppending = 8 Const ForReading = 1 Const ForWriting = 2 Const TristateFalse = 0 Const TristateMixed = -2 Const TristateTrue = -1 Const TristateUseDefault = -2 Const adTypeBinary = 1 Const adTypeText = 2 Const adSaveCreateNotExist = 1 Const adSaveCreateOverWrite = 2 blnSaveToFile = False ' Check command line arguments If WScript.Arguments.Unnamed.Count > 0 Then Syntax With WScript.Arguments.Named intArgs = 0 If .Exists("U") Then strURL = .Item("U") intArgs = intArgs + 1 End If If .Exists("F") Then strFile = .Item("F") intArgs = intArgs + 1 If Trim( strFile ) = "" Then strFile = WScript.ScriptFullName & "\..\WGet.txt" End If blnSaveToFile = True End If If intArgs <> .Count Then Syntax If intArgs = 0 Then Syntax If intArgs > 2 Then Syntax End With ' Use IE to retrieve the web page Set objIE = CreateObject( "InternetExplorer.Application" ) With objIE .Navigate strURL .Visible = False Do While .Busy WScript.Sleep 200 Loop strText = .Document.Body.InnerHTML Do While .Busy WScript.Sleep 200 Loop .Quit End With Set objIE = Nothing If blnSaveToFile Then ' Use ADODB stream to convert to and save as ASCII Set objADODB = CreateObject( "ADODB.Stream" ) With objADODB .Open .Type = adTypeText .CharSet = "us-ascii" .WriteText strText .SaveToFile strFile, adSaveCreateOverWrite .Close End With Set objADODB = Nothing Else WScript.Echo strText End If ' Help screen Sub Syntax Dim strMsg strMsg = vbcrlf _ & "WGet.vbs, Version 1.01" _ & vbCrLf _ & "Display a web page or save it as an ASCII text file" _ & vbCrLf & vbCrLf _ & "Usage:" & vbtab & "CSCRIPT //NoLogo WGET.VBS /U:""url"" [ /F:""file"" ]" _ & vbCrLf & vbCrLf _ & "Where:" & vbtab & """url""" & vbtab & "is the URL of the web page to be retrieved" _ & vbCrLf _ & " " & vbtab & """file""" & vbtab & "is the (optional) file where the text should be written to" _ & vbCrLf _ & " " & vbtab & " " & vbtab & "(will be overwritten if it exists, or created if not)" _ & vbCrLf & vbCrLf _ & "Notes:" & vbTab & "If /F is used without a file name, the result will be written to" _ & vbCrLf _ & " " & vbTab & "a file named WGet.txt, located in this script's parent directory." _ & vbCrLf _ & " " & vbTab & "If /F is not used, the result will be displayed on screen." _ & vbCrLf & vbCrLf _ & "Written by Rob van der Woude" _ & vbCrLf _ & "http://www.robvanderwoude.com" WScript.Echo strMsg WScript.Quit 1 End Sub