Conceited Forums RSS Feed

We have a very active and passionate community and our forums is the place to get tips and chat with other users about all our products. Join today and meet some great people! Note: if you have a feature to request or a bug to report, make sure you use this contact form.

 

This topic has been marked not a support question by our support staff or its poster.

  1. Zippo
    Member

    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!

    Posted 7 months ago #
  2. Zippo
    Member

    I forgot to edit the last part of the script... it should read:

    return "The current temperature in " & City & " is " & Temperature & "°C" & FeelsLike & ", and the weather condition for right now is " & CurrentWeather & "." & WeatherWarning

    This allows the script to grab the city name from the site automatically... so you don't have to manually type it in yourself.

    Posted 7 months ago #
  3. wnvoss
    Member

    Thanks, looks great!

    Posted 7 months ago #
  4. chapel
    Member

    I created the existing weather script and as far as I know any location will work as long as you put in the name that is understood. It might not be perfect, but even canadian zip codes work for me. Though the output is not perfect. I can update the script to be better of course.

    Posted 6 months ago #

Reply

You must log in to post.

© Conceited Software 2008. All rights reserved.