' ============================================= ' == Modify the following 3 variables: == ' ============================================= ' Specify the URL and the output file's destination directory strURL = "http://www.orindaben.com/db/dbmeditation/meditation.php" strDir = "C:\My Documents\" ' The current week number will be appended to the file name specified here strFilePrefix = "Orin and DaBen meditation for week " ' ============================================= ' == Modify the 3 variables above this line! == ' ============================================= ' Check for command line arguments (none required) If WScript.Arguments.Count Then Syntax ' Use our own error handling On Error Resume Next ' Retrieve text from specified URL strText = TextFromHTML( strURL ) ' Get week number and append it to text file name numWeek = DatePart( "ww", Date,vbSunday,vbFirstFourDays ) strFile = strDir & strFilePrefix & numWeek & ".txt" ' Create a new text file Set fso = CreateObject( "Scripting.FileSystemObject" ) Set fileHandle = fso.CreateTextFile( strFile, True ) ' Write the retrieved text to the new file fileHandle.Write strText ' Close the file fileHandle.Close ' Use default text editor to display text read from URL Set wshShell = CreateObject( "WScript.Shell" ) If Err Then ShowErr wshShell.Run( Quoted( strFile ) ) If Err Then ShowErr ' Normal program termination WScript.Echo 0 Sub ShowErr strMsg = "Error # " & Err.Number & vbCrLf _ & Err.Description & vbCrLf & vbCrLf WScript.Echo strMsg End Sub ' TextFromHTML() function by Rube Goldberg ' http://dev.remotenetworktechnology.com/wsh/rubegoldberg.htm Function TextFromHTML( URL ) Set objIE = CreateObject( "InternetExplorer.Application" ) If Err Then ShowErr objIE.Navigate URL If Err Then ShowErr Do Until objIE.ReadyState = 4 WScript.Sleep 10 Loop TextFromHTML = objIE.Document.Body.InnerText If Err Then ShowErr objIE.Quit End Function Function Quoted( str ) Quoted = Chr(34) & str & Chr(34) End Function Sub Syntax strMsg = vbCrLf _ & "Orin.vbs, Version 1.00" & vbCrLf _ & "Retrieve text from a URL and store it in a text file" & vbCrLf _ & "with the week number appended to its file name." _ & vbCrLf & vbCrLf _ & "Usage: CSCRIPT ORIN.VBS" _ & vbCrLf & vbCrLf _ & "I wrote this script for my wife, so she can automatically retrieve the" & vbCrLf _ & "text for a weekly meditation by Orin and DaBen and store it for later use." & vbCrLf _ & "That is why the week number is appended to the destination file name." & vbCrLf _ & "The URL and the destination of the text are hard coded into this script." & vbCrLf _ & "Adapt them to your own needs." _ & vbCrLf & vbCrLf _ & "The function to retrieve text from a URL was written by Rube Goldberg" & vbCrLf _ & "http://dev.remotenetworktechnology.com/wsh/rubegoldberg.htm" _ & vbCrLf & vbCrLf _ & "Written by Rob van der Woude" & vbCrLf _ & "http://www.robvanderwoude.com" WScript.Echo strMsg Wscript.Quit 1 End Sub