Extract Emails from a Web Page

This process prompts the user to enter a URL, retrieves all email addresses that are contained in the selected URL and stores them into a temporary file. It then launches the file using Notepad.

function DownloadWebPageText
    #Sends an http request to the specified address, and stores the returned web page in the "WebsiteText" variable.

    Web.Download Url:WebsiteSelected  \
                ConnectionTimeout:30 \
                FollowRedirection:True \
                ClearCookies:False \
                UserAgent:'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20100312 Firefox/3.6' \
                Encoding:'' \
                WebPageText=> g:WebsiteText

function ParseEmails
    #Parses the text that is contained in the "WebsiteText" variable (using Regular Expressions) for any email addresses. The list that contains the retrieved email addresses is stored into the variable "EmailsFound"

    Text.RegexParse Text:WebsiteText  \
                TextToFind:'([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})'  \
                StartingPosition:0  \
                IgnoreCase:False \
                OccurrencePositions=> OccurrencePositions \
                Matches=> g:EmailsFound

function WriteParsedEmails
    #If there are any email addresses in the URL that the user entered, loop through each of them. Store the email address of the current iteration in the variable "CurrentEmail"

    File.GetTempPath TempFile=> g:TempFile

    loop foreach item in EmailsFound
        File.WriteText File:TempFile  \
                TextToWrite:item  \
                AppendNewLine:True \
                IfFileExists:File.IfFileExists.Append \

Display.InputDialog Title:'Enter the URL' \
                Message:'Please enter the URL of the website whose emails you want to retrieve without the preceeding http:// (e.g www.google.com)' \
                DefaultValue:'' \
                InputType:Display.InputType.SingleLine \
                IsTopMost:False \
                UserInput=> WebsiteSelected \
                ButtonPressed=> ButtonPressed
#Checks if the user pressed the OK button in the previous dialog. If not (i.e if the user pressed the "Cancel" button), the main body of the job will not be executed.

if ButtonPressed='OK' then
    call DownloadWebPageText
    call ParseEmails
    call WriteParsedEmails
    System.RunApplication ApplicationPath:'notepad'  \
                CommandLineArguments:TempFile \
                WorkingDirectory:'' \
                WindowStyle:System.ProcessWindowStyle.Normal \
                ProcessId=> AppProcessId

Display.ShowMessage Title:'Process Completed!' \
                Message:'Process "Extract Emails from a Web Page" completed.' \
                Icon:Display.Icon.None \
                Buttons:Display.Buttons.OK \
                DefaultButton:Display.DefaultButton.Button1 \
                IsTopMost:False \
                ButtonPressed=> ButtonPressed