AppleScript- Getting Brandon Sanderson Project Updates read aloud.

I have been playing around making a Jarvis like home notifaction script.  One piece of that for fun is to read me the current Brandon Sanderson book project status report.  I made the below applescript to parse the information off his Web site and read it aloud to me. After all men don't read (a Stormlight Archive reference so go get the book).  I am a huge fan of his Mistborn and Stormlight Archive series.  Oh yeah... He is also finishing the Wheel of Time too. ;-)

Warning that the below script could break at any time.  It has to parse out bits of html code.  Who knows how much that changes each time updates his status.  I won't know till the next update.  You can see those bits in the AppleScript's text item delimeters lines in the script.

*UPDATE 9-18-2011* I updated the script below to help avoid breaking when Brandon updates his progress area.  It relies way less on the html code matching.

on run {}

try

set theSource to (do shell script "curl " & quoted form of ("http://www.brandonsanderson.com/"))

set AppleScript's text item delimiters to {"<h3>Current Projects</h3>"}

set theText to text item 2 of theSource

set AppleScript's text item delimiters to {"<h3>Search</h3>"}

set theText to text item 1 of theText

set AppleScript's text item delimiters to {"<div style=\"float:left;  width:100%;\">"}

set tempProject1 to text item 2 of theText

set tempProject2 to text item 3 of theText

set tempProject3 to text item 4 of theText

set percentStartProj1 to offset of "%" in tempProject1

set percentProj1 to text (percentStartProj1 - 3) thru (percentStartProj1) of tempProject1

set AppleScript's text item delimiters to {"  <br/>"}

set projectProgress1 to text item 1 of tempProject1 & percentProj1

set percentStartProj2 to offset of "%" in tempProject2

set percentProj2 to text (percentStartProj2 - 3) thru (percentStartProj2) of tempProject2

set AppleScript's text item delimiters to {"  <br/>"}

set projectProgress2 to text item 1 of tempProject2 & percentProj2

set percentStartProj3 to offset of "%" in tempProject3

set percentProj3 to text (percentStartProj3 - 3) thru (percentStartProj3) of tempProject3

set AppleScript's text item delimiters to {"  <br/>"}

set projectProgress3 to text item 1 of tempProject3 & percentProj3

set AppleScript's text item delimiters to {""}

say "Brandon Sanderson Project Status Report"

say projectProgress1

say projectProgress2

say projectProgress3

on error

say "Unable to obtain Brandon Sanderson project status information."

return

end try

end run