Weather Script:

OK, I have a weather script (I know I’m giving away my city’s location) and it works. To test the script, I changed the city to New York and it did not work, I tried EVERYTHING and nothing worked, here is the script:

property agent : "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3"
display dialog "Loading Weather Forcast; may a few seconds!" buttons {"OK"} default button 1 giving up after 2
set thedata to do shell script "curl " & "-A" & space & quoted form of agent & space & "http://www.accuweather.com/us/il/highland-park/60035/city-weather-forecast.asp" as string

--temp
set AppleScript's text item delimiters to "<div id=\"quicklook_current_temps\">"
set temp to text item 2 of thedata
set AppleScript's text item delimiters to "°F</div>\r\t\t\t\t\t\t<div id=\"quicklook_current_rf\">"
set temp to text item 1 of temp as integer

--feels like
set AppleScript's text item delimiters to "<div id=\"quicklook_current_rfval\">"
set feeltemp to text item 2 of thedata
set AppleScript's text item delimiters to "°F</div>\r\t\t\t\t\t\t<div class=\"textsmall\" style=\"margin-top:3px;\">"
set feeltemp to text item 1 of feeltemp as integer

--Description
set AppleScript's text item delimiters to "<div id=\"quicklook_current_wxtext\">"
set desc to text item 2 of thedata
set AppleScript's text item delimiters to "</div>\r\t\t\t\t<div id=\"quicklook_current_wxdataleft\">"
set desc to text item 1 of desc

--tomorrow high
set AppleScript's text item delimiters to "<div class=\"quicklook_day_tempdata\">"
set tomorrowdata1 to text item 2 of thedata
set AppleScript's text item delimiters to "\r\t\t\t\t\t\tHigh: "
set onetomorrowdata to text item 2 of tomorrowdata1
set AppleScript's text item delimiters to "°F<br/>"
set tomhigh to text item 1 of onetomorrowdata as integer

--15 day forcast curl
set thedata15 to do shell script "/usr/bin/curl" & space & ¬
	"-A" & space & quoted form of agent & space & ¬
	"-d" & space & quoted form of "partner=accuweather" & space & quoted form of "http://www.accuweather.com/us/il/highland%20park/60035/forecast.asp?"

--today low

set AppleScript's text item delimiters to "<div style=\"font-family: Arial; font-size: 12px; font-weight: bold; padding-top: 10px;\">Low: "
set todaydata to text item 2 of thedata15
set AppleScript's text item delimiters to " °F&nbsp"
set low to text item 1 of todaydata as integer

--tomorrow low

set AppleScript's text item delimiters to "<div style=\"font-family: Arial; font-size: 12px; font-weight: bold; padding-top: 10px;\">Low: "
set tomorrowdata2 to text item 5 of thedata15
set AppleScript's text item delimiters to " °F&nbsp"
set tomlow to text item 1 of tomorrowdata2 as integer

--tomorrow description
set AppleScript's text item delimiters to " <div style=\"font-family: Arial; font-size: 12px; font-weight: normal; padding-top: 5px;\">"
set tomdesc to text item 3 of thedata15 as string
set AppleScript's text item delimiters to "</div>\r        \t\t\t            </div>\r        \t\t\t            <div style=\"clear: both;\"></div>"
set tomdesc to text item 1 of tomdesc

--tonight description
set AppleScript's text item delimiters to " <div style=\"font-family: Arial; font-size: 12px; font-weight: normal; padding-top: 5px;\">"
set tondesc to text item 2 of thedata15 as string
set AppleScript's text item delimiters to "</div>\r        \t\t\t            </div>\r        \t\t\t            <div style=\"clear: both;\"></div>"
set tondesc to text item 1 of tondesc
-----------------------------------------------------------------------------------------
set dialog to "Weather for " & (current date) & return & return & "Today" & return & tab & desc & return & "\tNow: " & temp & "ºF" & return & "\tFeels like: " & feeltemp & "ºF" & return & "\tHigh: " & temp & "ºF" & return & "\tLow: " & low & "ºF" & return & return & "Tonight" & return & tab & tondesc & return & return & "Tomorrow" & return & tab & tomdesc & return & tab & "High: " & tomhigh & "ºF" & return & tab & "Low: " & tomlow & "ºF"
display dialog dialog buttons {"OK"} default button 1 with title "Weather"

Hi, Dylan.

Just to check: did “EVERYTHING” include changing the ZIP code in the URL?

Yes, I went to Accuweather online and searched New York and then copied the base URL (removing the stuff after the “?”) and then for the 15 day forcast, I I just added the question mark,
like it already is for Highland Park.

Here is an update to the script that DOES NOT solve my problem:

property agent : "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3"
display dialog "Loading Weather Forcast; may a few seconds!" buttons {"OK"} default button 1 giving up after 2
set thedata to do shell script "curl " & "-A" & space & quoted form of agent & space & "http://www.accuweather.com/us/il/highland-park/60035/city-weather-forecast.asp" as string

--temp
set AppleScript's text item delimiters to "<div id=\"quicklook_current_temps\">"
set temp to text item 2 of thedata
set AppleScript's text item delimiters to "°F</div>\r\t\t\t\t\t\t<div id=\"quicklook_current_rf\">"
set temp to text item 1 of temp as integer

--feels like
set AppleScript's text item delimiters to "<div id=\"quicklook_current_rfval\">"
set feeltemp to text item 2 of thedata
set AppleScript's text item delimiters to "°F</div>\r\t\t\t\t\t\t<div class=\"textsmall\" style=\"margin-top:3px;\">"
set feeltemp to text item 1 of feeltemp as integer

--Description
set AppleScript's text item delimiters to "<div id=\"quicklook_current_wxtext\">"
set desc to text item 2 of thedata
set AppleScript's text item delimiters to "</div>\r\t\t\t\t<div id=\"quicklook_current_wxdataleft\">"
set desc to text item 1 of desc

--tomorrow high
set AppleScript's text item delimiters to "<div class=\"quicklook_day_tempdata\">"
set tomorrowdata1 to text item 3 of thedata
set AppleScript's text item delimiters to "\r\t\t\t\t\t\tHigh: "
set onetomorrowdata to text item 2 of tomorrowdata1
set AppleScript's text item delimiters to "°F<br/>"
set tomhigh to text item 1 of onetomorrowdata as integer

--15 day forcast curl
set thedata15 to do shell script "/usr/bin/curl" & space & ¬
	"-A" & space & quoted form of agent & space & ¬
	"-d" & space & quoted form of "partner=accuweather" & space & quoted form of "http://www.accuweather.com/us/il/highland%20park/60035/forecast.asp?"

--today low

set AppleScript's text item delimiters to "<div style=\"font-family: Arial; font-size: 12px; font-weight: bold; padding-top: 10px;\">Low: "
set todaydata to text item 2 of thedata15
set AppleScript's text item delimiters to " °F&nbsp"
set low to text item 1 of todaydata as integer

--tomorrow low

set AppleScript's text item delimiters to "<div style=\"font-family: Arial; font-size: 12px; font-weight: bold; padding-top: 10px;\">Low: "
set tomorrowdata2 to text item 5 of thedata15
set AppleScript's text item delimiters to " °F&nbsp"
set tomlow to text item 1 of tomorrowdata2 as integer

--tomorrow description
set AppleScript's text item delimiters to " <div style=\"font-family: Arial; font-size: 12px; font-weight: normal; padding-top: 5px;\">"
set tomdesc to text item 3 of thedata15 as string
set AppleScript's text item delimiters to "</div>"
set tomdesc to text item 1 of tomdesc

--tonight description
set AppleScript's text item delimiters to " <div style=\"font-family: Arial; font-size: 12px; font-weight: normal; padding-top: 5px;\">"
set tondesc to text item 2 of thedata15 as string
set AppleScript's text item delimiters to "</div>"
set tondesc to text item 1 of tondesc

--today high/current temp
set AppleScript's text item delimiters to "<div style=\"font-family: Arial; font-size: 12px; font-weight: bold; padding-top: 10px;\">High: "
set todayhigh to text item 2 of thedata15
set AppleScript's text item delimiters to " °F&nbsp"
set todhigh to text item 1 of todayhigh as integer
-----------------------------------------------------------------------------------------
set dialog to "Weather for " & (current date) & return & return & "Today" & return & tab & desc & return & "\tNow: " & temp & "ºF" & return & "\tFeels like: " & feeltemp & "ºF" & return & "\tHigh: " & todhigh & "ºF" & return & "\tLow: " & low & "ºF" & return & return & "Tonight" & return & tab & tondesc & return & return & "Tomorrow" & return & tab & tomdesc & return & tab & "High: " & tomhigh & return & tab & "Low: " & tomlow
display dialog dialog buttons {"OK"} default button 1 with title "Weather"

Your working script for Highland Park didn’t work for me when I tried it, because the forecast ” and thus the layout of the page ” had changed. That’s probably why it didn’t work with the New York page, which would have been different anyway.

Looking just a little way through the present Highland Park page source with the script, I find that lines like .

set AppleScript's text item delimiters to "°F</div>\r\t\t\t\t\t\t<div id=\"quicklook_current_rf\">"

. are best reduced to:

set AppleScript's text item delimiters to "°F</div>

This catches the essential end tab after the number you want without being affected by whatever may happen to be in the page source after that.

Your “tomorrow high” section failed because the “High:” comes after the second instance of “<div class="quicklook_day_tempdata">” in the page source I’m viewing, so the script’s looking in the wrong text item.

I’ve got to get my Mum’s tea now, but basically, it’s the ever-changing nature of the page code that you have to try and trap.

Have you tried the rss feed to see if that provides the info you want. At least it will have a consistent format.

Umm… I think if the script just works with Highland Park, then I will not alter it anymore and not distribute it.

Your code works well when you change the parts in the top url

set thedata to do shell script "curl " & "-A" & space & quoted form of agent & space & "http://www.accuweather.com/us/il/highland-park/60035/city-weather-forecast.asp" as string

To

set thedata to do shell script "curl " & "-A" & space & quoted form of agent & space & "http://www.accuweather.com/us/ny/new-york/10001/city-weather-forecast.asp" as string

So just change the state,city,zip.

To get the rest to work.

change the 15day url

set thedata15 to do shell script "/usr/bin/curl" & space & ¬
	"-A" & space & quoted form of agent & space & ¬
	"-d" & space & quoted form of "partner=accuweather" & space & quoted form of "http://www.accuweather.com/us/il/highland%20park/60035/forecast.asp?

To

set thedata15 to do shell script "/usr/bin/curl" & space & ¬
	"-A" & space & quoted form of agent & space & ¬
	"-d" & space & quoted form of "partner=accuweather" & space & quoted form of "http://www.accuweather.com/us/ny/new-york/10001/forecast.asp?"

I did the for 3 cities. All worked.

It could be that by mistake when you went to test the other cites, you only went to the 5 day page to get the
url. The 5 day one has "/city-weather-forecast.asp" at the end. The 15day on has “/forecast.asp?”

The only other thing I noticed was you description are listing in the wrong sections…
I think you just need to change the order of placement.

Your code works well when you change the parts in the top url

set thedata to do shell script "curl " & "-A" & space & quoted form of agent & space & "http://www.accuweather.com/us/il/highland-park/60035/city-weather-forecast.asp" as string

To

set thedata to do shell script "curl " & "-A" & space & quoted form of agent & space & "http://www.accuweather.com/us/ny/new-york/10001/city-weather-forecast.asp" as string

So just change the state,city,zip.

To get the rest to work.

change the 15day url

set thedata15 to do shell script "/usr/bin/curl" & space & ¬
	"-A" & space & quoted form of agent & space & ¬
	"-d" & space & quoted form of "partner=accuweather" & space & quoted form of "http://www.accuweather.com/us/il/highland%20park/60035/forecast.asp?

To

set thedata15 to do shell script "/usr/bin/curl" & space & ¬
	"-A" & space & quoted form of agent & space & ¬
	"-d" & space & quoted form of "partner=accuweather" & space & quoted form of "http://www.accuweather.com/us/ny/new-york/10001/forecast.asp?"

I did this for 3 cities. All worked.

It could be that by mistake when you went to test the other cites, you only went to the first page to get the
url. The first page has "/city-weather-forecast.asp" at the end. The 15 day one has “/forecast.asp?”

The only other thing I noticed was you description are listing in the wrong sections…
I think you just need to change the order of placement.

The script only works for Highland Park at certain times of the day! When I visited the page yesterday morning (UK time), the “Quick Look” area showed “Today” with a “High” temperature followed by “Tonight” with a “Low” temperature. The script failed at this point. When I looked again last night, it was “Tonight” with a “Low” temperature followed by “Tomorrow” with a “High” temperature. This is the situation the script’s set up to catch and this part of it finally worked for me last night. However, it was then tripped up by something else further down.

The New York page seems to work on the same principle, so it seems likely that the page was showing different information from the Highland Park one when you looked because NY’s in a different time zone.

The situation’s probably get-roundable with a bit of thought, but you have to recognise that the page data change during the day and adjust your display goals accordingly.

Ok, the URL problem I solved by myself in the first try a week ago and would the timing problem be solved by try; on error; end try?

I’ve only had time so far to look at the “Quick Look” part of the script and the corresponding page code, so I’m not clear if you specifically want the “Tomorrow High” temperature (in which case the five- or fifteen-day forecast might be a more reliable place to get it) or whatever the second “Quick Look” figure happens to be (which only requires a small enhancement of your code).

I myself use ‘try . on error . end try’ principally to trap unexpected errors. I’d only use it to ignore inconvenient uncertainties as a last resort.

Hi,

my workflow for parsing html pages is:

¢ First cut the portion of the source you don’t need at all
¢ Get the information in order of appearance
¢ After using text items delimiters always use the rest (text items 2 thru -1) for the next search.
¢ If the location of the information is not constant check the occurrence of certain text elements or tags

I had a quick look at the yahoo Rss

This script (not my best- time constraints) works with the yahoo RSS feed.
To get the correct rss for you location. go to yahoo weather

Enter your location in the Enter city or zip code: search.
When you have your forecast. You should see a orange RSS button towards the top right of the page.
Control click on the RSS button to copy the link.
use the copied url in the script as I have, placing it in the curl command.

property agent : "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3"
display dialog "Loading Weather Forcast; may a few seconds!" buttons {"OK"} default button 1 giving up after 2


--Highland Park 
set theData to do shell script "curl " & "-L -A" & space & quoted form of agent & space & "http://us.lrd.yahoo.com/_ylt=AoqnOPSY8XQm7Hy4EkiBSdmLYDIB/SIG=1201d5f0r/**http%3A//weather.yahooapis.com/forecastrss%3Fp=USIL0539%26u=f" as string

--New York
--set theData to do shell script "curl " & "-L -A" & space & quoted form of agent & space & "http://us.lrd.yahoo.com/_ylt=AoqnOPSY8XQm7Hy4EkiBSdmLYDIB/SIG=1207hbvqk/**http%3A//weather.yahooapis.com/forecastrss%3Fp=USNY0996%26u=f" as string

--London
--set theData to do shell script "curl " & "-L -A" & space & quoted form of agent & space & "http://us.lrd.yahoo.com/_ylt=AoqnOPSY8XQm7Hy4EkiBSdmLYDIB/SIG=120cpqp74/**http%3A//weather.yahooapis.com/forecastrss%3Fp=UKXX0085%26u=f" as string

set aList to {}
set oSet1 to "<title>Conditions for"
set oSet2 to "</title>"
set currently to ""

my strip(oSet1, oSet2, theData, aList)
set oSet1 to "<b>Current Conditions:</b><br />"
set oSet2 to "<BR />"

my strip(oSet1, oSet2, theData, aList)
set oSet1 to "<BR /><b>Forecast:</b><BR />"
set oSet2 to "<br />" & return & "<br />" & return & "<a href"

my strip(oSet1, oSet2, theData, aList)
set ForecastToday to ""
set ForecastTM to ""
copy ForecastTM to end of aList
log aList
try
	set theBreak to "<br />"
	set breakNumber to (offset of theBreak in (item 3 of aList))
	set ForecastToday to text 1 thru (breakNumber - 1) of (item 3 of aList)
	log ForecastToday
	set ForecastTM to text -1 thru (breakNumber + (((count of theBreak) + 1))) of (item 3 of aList)
	log ForecastTM
	if ForecastToday is not "" then set (item 3 of aList) to ForecastToday
	if ForecastTM is not "" then set (item 4 of aList) to ForecastTM
end try
set Weather_for to (item 1 of aList)
set Current_Conditions to (item 2 of aList)
set The_Forecast4today to (item 3 of aList)
set The_Forecast4tom to (item 4 of aList)
set dialog to "Weather for " & Weather_for & return & return & "Current Conditions:" & return & return & tab & Current_Conditions & return & return & "Forecast: " & return & return & tab & The_Forecast4today & return & tab & The_Forecast4tom
display dialog dialog buttons {"OK"} default button 1 with title "Weather"


on strip(oSet1, oSet2, theData, aList)
	set textNumber1 to (offset of oSet1 in theData)
	set theData1 to text -1 thru (textNumber1 + (count of oSet1)) of theData
	set textNumber2 to (offset of oSet2 in theData1)
	set textString2 to text from word 1 to (textNumber2 - 1) of theData1
	set theData to theData1
	copy textString2 to end of aList
end strip



Although I have tested this and it all works, the same issues of data and format changes to the pages most likely
still apply.

There are other RSS feeds for weather which may give more details, but this is just a demo…

Also I have used [b]offset of in[/b rather than applescript delimiters. mainly because I have never really like using them.

Edit
just did a small edit, as a line ending was getting change when copied back from this page.

And here is another (none RSS)

Which uses textutil to strip most of the html from the curl’ed page.

This uses the webpage http://weather.yahoo.com/
just enter you location as in the above post , but this time use the url in the address field.

I did two searches in this, which can easily be cut down or added to.

The oSet1, oSet2 are what is used to search from and upto
And is what I should have pointed out in the above post…

I did notice the london page had a class= night after one of the search terms, but in others I test with they did not.
So there is a check for this.
To make the dialog look better you can set the returned text to paragraphs of, so you can format better.
hope this helps…

property agent : "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3"
display dialog "Loading Weather Forcast; may a few seconds!" buttons {"OK"} default button 1 giving up after 2

set theData to do shell script "curl " & " -A" & space & quoted form of agent & space & "http://weather.yahoo.com/united-states/illinois/highland-park-2421549/" as string
--set theData to do shell script "curl " & " -A" & space & quoted form of agent & space & "http://weather.yahoo.com/england/greater-london/london-44418/" as string
--set theData to do shell script "curl " & " -A" & space & quoted form of agent & space & "http://weather.yahoo.com/france/auvergne/france-29332634/" as string

set aList to {}
set oSet1 to "<div id=\"yw-forecast\" >"
set oSet2 to "<ul>"
my strip(oSet1, oSet2, theData, aList)

set t_today to (do shell script "echo " & quoted form of (last item of aList) & "|textutil -format html -convert txt -stdin -stdout")
if text of t_today contains "W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">" then
	
	set oSet1 to " <div id=\"yw-forecast\" class=\"night\">"
	set oSet2 to "<ul>"
	my strip(oSet1, oSet2, theData, aList)
	set t_today to (do shell script "echo " & quoted form of (last item of aList) & "|textutil -format html -convert txt -stdin -stdout")
	
end if



set oSet1 to "How to Read This</a>"

set oSet2 to "View 6-10 Day Extended Forecast"
my strip(oSet1, oSet2, theData, aList)
set t_dits to (do shell script "echo " & quoted form of (last item of aList) & "|textutil -format html -convert txt -stdin -stdout")
on strip(oSet1, oSet2, theData, aList)
	set textNumber1 to (offset of oSet1 in theData)
	set theData1 to text -1 thru (textNumber1 + (count of oSet1)) of theData
	set textNumber2 to (offset of oSet2 in theData1)
	set textString2 to text from word 1 to (textNumber2 - 1) of theData1
	set theData to theData1
	copy textString2 to end of aList
end strip
log item 1 of aList
display dialog (t_today & return & t_dits as string) buttons {"OK"} default button 1 with title "Weather"

Oh… Thanks. I redesigned my weather script and it works fine, but this one is good, too!

Cheers…

I have re written the above one, to display with growl…
. It displays the “Loading Weather Forecast” first using the nano display and 2 second duration
Which slides out and back from the menu bar.

Then the Current data ( reformatted ) and Forecast in two separate growl windows. Using the brushed display and play 'Tink" sound
The code sets the brushed display to sticky.

The brushed display allows room for all the text.

I can then call it using a hotkey app like Spark.

I have in the past looked at weather scripts, but once I wrote them i never used them.
(probably because the weather in the UK is always crap)
Thanks for getting me to look at them again. I think this one will get a lot of use.
I may even set it to run first thing in the morning, so it ready and waiting when I get up.

If you want me to post the new code I can do so, but did not want to clutter up the post more than I already have…
:stuck_out_tongue:

I, for my part, spent an hour or so last night trying to debug the “15 day forcast” part of the original script. Most of the time was spent being baffled by the fact that yesterday’s date, which I could clearly see on the Web page, wasn’t showing up in the source code returned by the shell script. It turned out that the shell script URL was actually for the 5-day forecast, where the date was shown as “Today”.

Thanks for staying up last night?
You just reminded me I was doing the same thing all this time and my script works fine. Here it is:

property agent : "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3"
display dialog "Loading Weather Forcast; may a few seconds!" buttons {"OK"} default button 1 giving up after 2
set thedata to do shell script "curl " & "-A" & space & quoted form of agent & space & "http://www.accuweather.com/us/il/highland-park/60035/city-weather-forecast.asp" as string

--temp
set AppleScript's text item delimiters to "<div id=\"quicklook_current_temps\">"
set temp to text item 2 of thedata
set AppleScript's text item delimiters to "°F</div>\r\t\t\t\t\t\t<div id=\"quicklook_current_rf\">"
set temp to text item 1 of temp as integer

--feels like
set AppleScript's text item delimiters to "<div id=\"quicklook_current_rfval\">"
set feeltemp to text item 2 of thedata
set AppleScript's text item delimiters to "°F</div>\r\t\t\t\t\t\t<div class=\"textsmall\" style=\"margin-top:3px;\">"
set feeltemp to text item 1 of feeltemp as integer

--Description
set AppleScript's text item delimiters to "<div id=\"quicklook_current_wxtext\">"
set desc to text item 2 of thedata
set AppleScript's text item delimiters to "</div>\r\t\t\t\t<div id=\"quicklook_current_wxdataleft\">"
set desc to text item 1 of desc

--tomorrow high
set AppleScript's text item delimiters to "<div class=\"quicklook_day_tempdata\">"
set tomorrowdata1 to text item 3 of thedata
try
	set AppleScript's text item delimiters to "\r\t\t\t\t\t\tHigh: "
	set onetomorrowdata to text item 2 of tomorrowdata1
on error
	set AppleScript's text item delimiters to "<div class=\"quicklook_day_tempdata\">"
	set tomorrowdata1 to text item 2 of thedata
	set AppleScript's text item delimiters to "\r\t\t\t\t\t\tHigh: "
	set onetomorrowdata to text item 2 of tomorrowdata1
end try
set AppleScript's text item delimiters to "°F<br/>"
set tomhigh to text item 1 of onetomorrowdata as integer

--15 day forcast curl
set thedata15 to do shell script "/usr/bin/curl" & space & ¬
	"-A" & space & quoted form of agent & space & ¬
	"-d" & space & quoted form of "partner=accuweather" & space & quoted form of "http://www.accuweather.com/us/il/highland%20park/60035/forecast.asp?"

--today low

set AppleScript's text item delimiters to "<div style=\"font-family: Arial; font-size: 12px; font-weight: bold; padding-top: 10px;\">Low: "
set todaydata to text item 2 of thedata15
set AppleScript's text item delimiters to " °F&nbsp"
set low to text item 1 of todaydata as integer

--tomorrow low

set AppleScript's text item delimiters to "<div style=\"font-family: Arial; font-size: 12px; font-weight: bold; padding-top: 10px;\">Low: "
set tomorrowdata2 to text item 3 of thedata15
set AppleScript's text item delimiters to " °F&nbsp"
set tomlow to text item 1 of tomorrowdata2 as integer

--tomorrow description
set AppleScript's text item delimiters to " <div style=\"font-family: Arial; font-size: 12px; font-weight: normal; padding-top: 5px;\">"
set tomdesc to text item 3 of thedata15 as string
set AppleScript's text item delimiters to "</div>"
set tomdesc to text item 1 of tomdesc

--tonight description
set AppleScript's text item delimiters to " <div style=\"font-family: Arial; font-size: 12px; font-weight: normal; padding-top: 5px;\">"
set tondesc to text item 2 of thedata15 as string
set AppleScript's text item delimiters to "</div>"
set tondesc to text item 1 of tondesc

--today high/current temp
set AppleScript's text item delimiters to "<div style=\"font-family: Arial; font-size: 12px; font-weight: bold; padding-top: 10px;\">High: "
set todayhigh to text item 2 of thedata15
set AppleScript's text item delimiters to " °F&nbsp"
set todhigh to text item 1 of todayhigh as integer
-----------------------------------------------------------------------------------------
set dialog to "Weather for " & (current date) & return & return & "Today" & return & tab & desc & return & "\tNow: " & temp & "ºF" & return & "\tFeels like: " & feeltemp & "ºF" & return & "\tHigh: " & todhigh & "ºF" & return & "\tLow: " & low & "ºF" & return & return & "Tonight" & return & tab & tondesc & return & return & "Tomorrow" & return & tab & tomdesc & return & tab & "High: " & tomhigh & "ºF" & return & tab & "Low: " & tomlow & "ºF"
display dialog dialog buttons {"OK"} default button 1 with title "Weather"

Another option is to get the weather info you want from a NOAA XML file, such as:


tell application "URL Access Scripting"
	set weatherURL to "http://www.weather.gov/xml/current_obs/KTPA.xml"
	set filePath to (path to desktop as Unicode text) & "weather.xml"
	download weatherURL to filePath replacing yes
end tell

tell application "URL Access Scripting" to quit

tell application "System Events"
	tell XML element 1 of contents of XML file filePath
		set weatherText to (value of XML element "weather")
		set temperatureText to (value of XML element "temp_f")
	end tell
end tell

tell application "Finder" to delete file filePath

set weatherText to do shell script "echo " & quoted form of weatherText & " | tr \"[:upper:]\" \"[:lower:]\""

set myWeather to "Currently in Tampa it is " & weatherText & " and " & temperatureText & " F."