Find text in webpage and email notification using applescript/automator
I don't have much experience in automator/applescript.
I need a script that searches a web page for a string of text, then if that text is found, it sends me an email. It should reload the page and search again about every 10 minutes. Ideally, this would all occur in the background, but I can live without that feature.
I found this thread from way back in 2011 which is exactly what I'm after, but I'm thinking something has changed over the years, because attempting to run it results in a syntax error.
Can anyone help with an update or explanation? Here is the original script:
on idle
set pagURL to "http://page.url.com?whatever"
if application "Safari" is not running then
quit
return
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
makenewto recipientat end of to recipientswith properties {address:"email@adress.com"}
end tell
-- send theMess
end tell
end sendAMail
When I try to run the script in Automator, I get the following error: