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.
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 AppleScript‘s text item delimiters to {“<br/> <div style=\”width:33.99px; overflow:hidden; float:left; \”><img src=\”/templates/slate/images/bookmeter1.png\” /></div><div style=\”float:left; padding-left:5px;\”> “}
set projectProgress1 to text item 1 of tempProject1 & text item 2 of tempProject1
set AppleScript‘s text item delimiters to {” <br/> <div style=\”width:103px; overflow:hidden; float:left; \”><img src=\”/templates/slate/images/bookmeter2.png\” /></div><div style=\”float:left; padding-left:5px;\”> “}
set projectProgress2 to text item 1 of tempProject2 & text item 2 of tempProject2
set AppleScript‘s text item delimiters to {” <br/> <div style=\”width:57.68px; overflow:hidden; float:left; \”><img src=\”/templates/slate/images/bookmeter3.png\” /></div><div style=\”float:left; padding-left:5px;\”> “}
set projectProgress3 to text item 1 of tempProject3 & text item 2 of tempProject3
set AppleScript‘s text item delimiters to {“</div>”}
set projectProgress1 to text item 1 of projectProgress1
set projectProgress2 to text item 1 of projectProgress2
set projectProgress3 to text item 1 of projectProgress3
set AppleScript‘s text item delimiters to {“”}
say “Brandon Sanderson Project Status Report”
sayprojectProgress1
sayprojectProgress2
sayprojectProgress3
on error
say “Unable to obtain Brandon Sanderson project status information.”
return
end try
end run
Posted via email from georgestarcher.randomlings