A script that monitors an url non-stop?

Howdy Dudes!

Is it possible and how should I make an applescript that monitors, continuosly (non-stop), an url and if there ther is somethint then say it (text-to-speech)?

Example, the url monitors the url http://www.example.com/text.html
As soon as the text.html conains something it speaks it out (using say). No need for any complex analysis, the text.html will conain only the readable text.

All ideas welcome! Thanks already!

Hi,

easiest version:


set theURL to "http://macscripter.net/viewtopic.php?pid=120776#p120776"
repeat
	try
		set curl to "/usr/bin/curl -s --connect-timeout 25 -m 120 " & quoted form of theURL
		set theData to do shell script curl & " | textutil -stdin -stdout -format html -convert txt -encoding UTF-8"
		if theData is not "" then say theData
	end try
end repeat

curl reads the source of the html page, a timeout handling is included
textutil strips the html tags and converts the source to plain text.

Thanks, that looks cool :smiley:

I’m not good with AppleScript so I have to ask,

  • is this doing this loop endless? That is what I would want … More specific, can this AppleScript run whole day long, repeat itself, until it is stopped for example from the web page it’s page it’s reading (with a special phrase)

  • how should the line look if the webpage is only text already (not tags, no html, only the text)?

try this


set theURL to "http://macscripter.net/viewtopic.php?pid=120776#p120776"
repeat
	try
		set theData to do shell script "/usr/bin/curl -s --connect-timeout 25 -m 120 " & quoted form of theURL
		if theData is "mySpecialPhrase" then
			exit repeat
		else if theData is not "" then
			say theData
		end if
	end try
end repeat

Thank you StefanK, this is working great! You’re best!

I tested this and this is a really easy way to get my web pages to talk. Combined with php and databases, the web page knows when the phrase is read, can change the phrases dynamically. even put out the right phrase to right Mac!