Grab Web Page into NoteTab Text Editor11 Jan 2009
One of my favourite clips is one that provides a basic integration with a command line utility to download a web page without having to go into your web browser and view it.
So if you don’t already have them download the following free pieces of software:
- NoteTab Light - text editor with scripting capabilities.
- wGet - command line utility for downloading files from the Internet.
The two clips below should be copied and pasted into an appropriate clip library in NoteTab (see the NoteTab help file on how to do this - it’s very straight forward). Run the “Grab Web Page” clip and after specifying what URL to download, where to download it to, how to display it (open the downloaded file, copy the file content into a new file or insert the file content at the current cursor position) and what log file to log the activity to.
H="Grab Web Page" ;Initialise variables ^!Set %FETCH_URL%=^?[URL of web page to retrieve=http://rebootit.wordpress.org] ^!Set %OUTPUT_PATH%=^?[(T=D)Directory to download file to=c:wGet Output] ^!Set %INSERTION_TYPE%=^?[(T=C)Downloaded file==_Open|Copy into new file|Insert at cursor] ^!Set %LOG_PATH%=^?[(T=S;F="Log Files (*.log)|*.log")File to log download progress to=c:wGet Outputoutput.log] ^!Set %WGET_PATH%=^?[Path to wGet.exe=C:Program FilesCommand line Utilitieswget.exe] ;Remove trailing backslash if it exists - wGet doesn't like these ^!If "^$StrCopyRight("^%OUTPUT_PATH%";1)$"="" NEXT Else SKIP ^!Set %OUTPUT_PATH%=^$StrDeleteRight("^%OUTPUT_PATH%";1)$ ;Create the output directory ;(If it exists it won't do any harm) ^!MkDir ^%OUTPUT_PATH% ;Fetch page ^!CmdShow MINIMIZE ^!Set %FETCH_OUTPUT%=^$GetOutput("^%WGET_PATH%" -P"^%OUTPUT_PATH%" -nv -o"^%LOG_PATH%" "^%FETCH_URL%")$ ;Get the name the retrieved file was named as ^!Set %OUTPUT_FILE_PATH%=^$GetFileText(^%LOG_PATH%)$ ^!Set %OUTPUT_FILE_PATH%=^$StrDeleteLeft("^%OUTPUT_FILE_PATH%";^$Calc(^$StrPos("-> ";"^%OUTPUT_FILE_PATH%";TRUE)$+3)$)$ ^!Set %OUTPUT_FILE_PATH%=^$StrCopyLeft("^%OUTPUT_FILE_PATH%";^$Calc(^$StrPos(""";"^%OUTPUT_FILE_PATH%";TRUE)$-1)$)$ ^!Set %OUTPUT_FILE_PATH%=^$StrReplace("/";"";"^%OUTPUT_FILE_PATH%";TRUE;TRUE)$ ;Output the contents of the downloaded file ^!If "^%INSERTION_TYPE%"="Open" NEXT Else SKIP ^!Open ^%OUTPUT_FILE_PATH% ^!If "^%INSERTION_TYPE%"="Copy into new file" NEXT Else SKIP ^!Clip "New From Text" ^$GetFileText(^%OUTPUT_FILE_PATH%)$ ^!If "^%INSERTION_TYPE%"="Insert at cursor" NEXT Else SKIP ^!InsertFile ^%OUTPUT_FILE_PATH% H="_New From Text" ^!Menu File/New ^!InsertCode ^&