I was never able to get the included weather script to work for me, so I (with the help of some people on the Apple forums) wrote this one:
on linkinuscmd(WebAddress)
set WebAddress to "http://mobile.theweathernetwork.com/weather/canf0253"
do shell script "/usr/bin/curl " & WebAddress & " | /usr/bin/textutil -stdin -convert txt -stdout" -- get source and strip HTML
tell the result -- get the various elements
set City to paragraph 5
set WeatherWarning to paragraph 8
if (count WeatherWarning) > 1 then -- there is a weather warning
set CurrentWeather to paragraph 11
set Temperature to paragraph 12
set FeelsLike to paragraph 13
set WeatherWarning to "- There is currently a " & WeatherWarning & " in effect."
else
set CurrentWeather to paragraph 9
set Temperature to paragraph 10
set FeelsLike to paragraph 11
end if
end tell
set City to text 1 thru -4 of City -- strip off extra space
set Temperature to text 1 thru -3 of Temperature -- strip off the ending degree and C characters
if FeelsLike contains "wind" then -- not a valid wind chill or humidity index
set FeelsLike to ""
else
set FeelsLike to text 13 thru -2 of FeelsLike -- strip off everything but numbers
set FeelsLike to " and feels like " & FeelsLike & "°C"
end if
return "The current temperature in St. John's, NL is " & Temperature & "°C" & FeelsLike & ", and the weather condition for right now is " & CurrentWeather & WeatherWarning
end linkinuscmd
This polls the Canadian Weather Network's mobile website (for simplicity) and then returns a line similar to the following: "The current temperature in St. John's, NL is 21°C, and the weather condition for right now is A few clouds".
If there's a humidex or wind chill in effect, it'll add that too.
Example: "The current temperature in Tokyo is 24°C and feels like 32°C, and the weather condition for right now is A few clouds".
The only thing you'd need to do in order to customize it to your own city or town, is change the city code in web address at the top of the script to your own. (you can find this out by going to the site and clicking the Edit button, then find your own city/town and copy the address.
Enjoy!




not a support question by our support staff or its poster.
Reply
You must log in to post.