One of my co-workers is a big Mitch Hedburg fan, so I whipped up this 'script for him.
When run, it visits hedburg.com to obtain a random joke or other Mitch quote, strips the formatting and reads it out loud.
Note, it relies on the random http://hedburgh.com/quoter.php at hedburg.com”there are no quotes stored in the script itself.
The code is simple, and would serve for lots of different grab-parse-and-process applications. Nonetheless, I am open to any suggestions to improve it!
set theSource to do shell script "curl [url=http://hedburgh.com/quoter.php]http://hedburgh.com/quoter.php"[/url]
set theQuote to (extractBetween(theSource, "<td>", "</td>")) as text
set theQuote to (my replaceThings(theQuote, "\\", ""))
say theQuote
on replaceThings(txt, srch, repl)
set AppleScript's text item delimiters to the srch
set the item_list to every text item of txt
set AppleScript's text item delimiters to the repl
set txt to the item_list as string
set AppleScript's text item delimiters to ""
return txt
end replaceThings
to extractBetween(SearchText, startText, endText)
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to startText
set endItems to text of text item -1 of SearchText
set AppleScript's text item delimiters to endText
set beginningToEnd to text of text item 1 of endItems
set AppleScript's text item delimiters to tid
return beginningToEnd
end extractBetween