Data extraction from HTML using AppleScript.
I attempted to do some data extraction using some Applescript found here and elsewhere, with some modifications that I could figure out, then gave it up for a while. But this is still bugging me.
Here's what the HTML source looks like.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
A lot of unneeded data to start.
Portfolio Header Data
<h2 class="red"><a href="http://www.stockresearch.com/my/portfolio/portfolio1" class="red">Portfolio #1</a></h2>
Begin Stock Data
<div class="row lightgrey">
<div class="company"><a href="http://www.stockresearch.com/my/portfolio/stock-detail/324/" class="red">Company #1</a></div>
<div class="sym-price"> <a href="javascript:goQuote1('T.ABC');">T.ABC</a><br>$12.87</div>
<div class="sym-price"> <a href="javascript:goQuote1('ABC');">ABC</a><br>$13.05</div>
<div class="rec"> <a style="cursor: pointer;" id="recTip_4" onMouseOver="bnToolTip.showRec(this.id)" onMouseOut="bnToolTip.hideRec();">Best B; B 1st tranche at $13, 2nd at $12</a></div>
<div class="last-updated">01/08/2013</div>
<div class="add-to-my-stocks"><input type="checkbox" name="stock[]" value="324"/></div> <div class="clr"></div>
End Stock Data
A lot of unneeded data to end.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
The data I hope to extract is bolded and blued above.
Here's how the data is grouped.
One <h2>, (Portfolio Header Data)
followed by 1 - 50 groups of Stock Data (from class="company" to class="last-updated").
ETC.
The above will repeat five times, though it might be more in the future.
At least some prior attempts have passed compile, but would error out when run.
Extraction to a csv would be ideal, though a text file or similar is just fine too.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
How can I proceed with this? Any help is much appreciated.
MacBook Pro (15-inch Late 2008), OS X Mountain Lion (10.8.2), 2.4GHz CPU, 8GB Ram, 250 GB HD