Grab Web Page into NoteTab Text Editor


NoteTab is a favoured text editor of mine and for a number of years I’ve used it for working with web pages and coding up HTML, PHP, Javascript and the like.  One of the best features of NoteTab (beyond the light version being free to download) is its powerful scripting language – creating what is known as NoteTab Clips.

Grab Web Page clip inputs

Grab Web Page clip inputs

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)

;Fetch page
^!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%"="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 ^&

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: