Hey Rob,
Here's why it's generally better to do things as directly as possible.
I used a fairly brute-force approach here, because I find the table-rows I want and then systemically strip off the junk I don't want.
If I were doing this for myself I would eventually streamline the script, but this way I was able to do the job in about 20 minutes or less.
You open the page in Safari and run the script.
A fraction of a second later you have a tab-delimited, date-stamped report on your Desktop ready to be imported or pasted into Excel (and that could be automated too).
Note that you don't need Smile — just the Satimage.osax — not that I'm discouraging anyone from using Smile — it's a very powerful if difficult to master automation tool.
The Satimage.osax installer installs 1 osax file:
/Library/ScriptingAdditions/Satimage.osax
It's safe. I've been using it since 2003.
-Chris
Edit: 2015/08/09 15:03 — I am highly P.0.'d to find that the forum is rendering text in a code-block and mangling it. Therefore I am posting a text script (.applescript) file for download.
Tab-Delimted-Report.applescript.zip (1.5 KB)
------------------------------------------------------------
-- Create Tab-Delimted Report on Desktop from:
-- http://www.asx.com.au/asx/statistics/prevBusDayAnns.do
-- REQUIRES SATIMAGE.OSAX
-- http://tinyurl.com/dc3soh
-- USE THE DOWNLOADABLE FILE ABOVE AND NOT THIS TEXT!!!!
------------------------------------------------------------
set _text to safariOuterHTML()
set foundList to fnd("(?m)^<tr class=\"(?:altrow)?\">[\\n\\r]<td>(?-i)[A-Z]{3}(?i)</td>.+?</tr>", _text, true, true) of me
set foundList to cng("\\r", "\\n", foundList) of me
set foundList to cng("<tr class=\"(?:altrow)?\">\\n", "", foundList) of me
set foundList to cng("</?td>", "", foundList) of me
set foundList to cng("</tr>", "", foundList) of me
set foundList to cng("<td class=\"pricesens\">.+title=[[:punct:]](price sensitive)[[:punct:]]>", "\\1", foundList) of me
set foundList to cng("<a onclick.+?href=[[:punct:]]", "", foundList) of me
set foundList to cng("[[:punct:]]>PDF</a>", "", foundList) of me
set foundList to cng("(/asx/)", "http://www.asx.com.au\\1", foundList) of me
set foundList to cng("&", "&", foundList) of me
set foundList to cng("^[[:blank:]]*$\\n", "", foundList) of me
set foundList to cng("\\A\\s+|\\s+\\Z", "", foundList) of me
set foundList to cng("\\n", "\\t", foundList) of me
set foundList to join foundList using return
set reportName to "ASX Announcements " & (strftime (current date) into "%Y.%m.%d · %H.%M.%S")
writetext foundList to ("~/Desktop/" & reportName) & ".txt"
------------------------------------------------------------
--» HANDLERS
------------------------------------------------------------
on cng(_find, _replace, _data)
change _find into _replace in _data with regexp without case sensitive
end cng
------------------------------------------------------------
on fnd(_find, _data, _all, strRslt)
try
find text _find in _data all occurrences _all string result strRslt with regexp without case sensitive
on error
return false
end try
end fnd
------------------------------------------------------------
on safariOuterHTML()
tell application "Safari"
tell front document to return do JavaScript "window.document.documentElement.outerHTML"
end tell
end safariOuterHTML
------------------------------------------------------------