Skip navigation

Find text in webpage and email notification applescript/automator

2565 Views 6 Replies Latest reply: Apr 8, 2012 5:09 AM by Reelin123 RSS
jrdrumbum3896 Calculating status...
Currently Being Moderated
Jun 16, 2011 10:37 AM

Hey guys, I'm trying to make (what I think is) a fairly complicated automator/applescript action.  Basically, I'm trying to buy a certain product and it is only available on the webpage at certain times. So I want to create a function that will constantly run in the background on my computer. I want this function to reload a safari page every 10-15 minutes (the one with the store's product page), search for text (the name of the product) and either stop there if the text isn't found or if the text is found, open mail and send myself an email notification so that I'll get it on my phone if the product becomes available. Is this possible at all?

Mac mini, Mac OS X (10.5.8)
  • twtwtw Level 5 Level 5 (4,580 points)

    this might do what you're looking for:

    on idle

              set pagURL to ""

              if application "Safari" is not running then



              end if

              tell application "Safari"

                        set URL of document 1 of window 1 to "http://your.web.address/"

                        delay 5

      -- delay to let page load. 

      -- there are more elegant ways of doing this using do javascript, but this will suffice.

                        if source of document 1 of window 1 contains "search text" then

                                  my sendAMail()

                        end if

                        return 900 --fifteen minutes

              end tell

    end idle


    on sendAMail()

              tell application "Mail"

                        set theMess to make new outgoing message at end with properties {sender:"your name", subject:"some subject line", content:"The message you want to send to yourself", visible:true}

                        tell theMess

                                   make new to recipient at end of to recipients with properties {address:""}

                        end tell

      -- send theMess

              end tell

    end sendAMail

    copy it into the applescript editor, edit in all the correct information about the web page, your email address, etc., then save it as a stay open application.  when run, it will periodically reload and check the page - adjust the number after the return statement to set it to different time periods.


    test it first, then when you're ready to use it set visible:false in the line where you make the message, and uncomment the send theMess line.  this will get mail to make and send the message invisibly.

  • twtwtw Level 5 Level 5 (4,580 points)

    for 15 mintes use return 900 in the idle loop. for an hour use return 3600.  Just use the appropriate number of seconds.

  • Reelin123 Level 1 Level 1 (0 points)

    Hi, I have a similar problem. Next week a new limited edition product will be available. When it comes out some redemption codes will be posted on the site. I already have an auto refresh extension on safari but i would like a script to autmatically copy the code as soon as it is posted. it will contain numbers, letters and - .




More Like This

  • Retrieving data ...

Bookmarked By (0)


  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.