Validate Approach for WebPage comparison, please

Good day.

I’m new to AS and in thinking about practical exercises I could use to explore and learn, one which came to mind is to write a reminder script. I have a habit of forgetting to go to the newstand every 3 months to purchase a quarterly publication and since the actual release date is sometime within the middle month of each quarter, I wondered if AS could take care of this for me…

The publisher has this HTML code on the front page of their website:

Current issue: Spring 2009

View Cover

the issue currently available is embedded in this HTML in two separate places:
Current issue: XXXXXXX

psuedo code:

– run this script every day if month is middle month of a calendar quarter(i.e. Feb, May, Aug, Nov)
– compare the value for current issue available to the value of a variable from the most recent script execution (no idea how to have a previous result compared to current result)
– if the value of the string has changed, display a dialog which states “Issue should be available at borders in the next couple of days”


Not to appear ungracious, but at this point, I’m not looking for any code suggestions, just comments on the basic approach. I’m sure that I’ll be back for suggestions/please for help with syntax, etc, but I learn better if I have to work through the issues from scratch ~

In advance…


assuming that the website contains plain html text, the string appears only once in the text
and there is no line break character in the line, you can try something like this

set t to do shell script "curl '' | grep ''"

set {TID, text item delimiters} to {text item delimiters, "Current issue: "}
set searchResult to text item 2 of t
set currentIssue to stripText(searchResult, "<") --> currentIssue contains "Spring 2009"
set text item delimiters to ""
set searchResult to text item 2 of t
set issue to stripText(searchResult, "\"") --> issue contains "sp09"
set text item delimiters to {""}

on stripText(t, v)
	return text 1 thru ((offset of v in t) - 1) of t
end stripText

Stefan ~

many thanks for the late night suggestion…

I’ll start building the script tonight and revert with my progress (assuming there is some :slight_smile: )