This has been me off and on the past couple of days:
My Matrix bots have been providing me with a few weather details ever since I set that StatusNet instance up. I have a little bash script that will pull the data on a set schedule via cron. Previously, I had been using google’s “secret” weather api as it pulled quickly, is easily parsed, didn’t require an account and had just the few details that I wanted. Judging from the error message I get when attempting to open the xml feed in my browser, they’ve blocked my IP and or domain:
After a quick search, it turns out the api was shut down. This has also had an effect on my XMPP jsonbot as it uses the google feed for it’s weather as well.
So, now it was time to find another place to pull from. I prefer to pull from an api as opposed to scraping a page somewhere. I really hate having a script fail due to the page being scraped changing something in it’s layout. In the past, my first stop would have been weather.com but, they made some changes a while back and no longer have a free api to hit. So, my first (and only) stop this time was wunderground.com. I haven’t visited the Wunderground site much but, have been seeing it referenced more and more lately. Plus, I have an interest in getting a personal weather station eventually, which can report to Wunderground if desired.
It turns out, Wunderground has a free api (after signing up) that is quite extensive (at least compared to the google feed) and very well documented. The script that I had to pull the weather was just parsing xml and it was quick and easy to change to the Wunderground api.
Before:
After:
I also decided that I’d also like for a little forecast as well. Not a full, multi day forecast but, just an outlook of the next few hours or so. Was quite easy with the Wunderground api actually.
Most likely, there are much easier ways to parse the xml or json feeds returned by the api but, I stuck to good ol’ bash. Examples of the scripts that I ended up with can be found here: current conditions and forecast. Both of these have a few options at the start of the scripts. Also, the forecast script will pull multiple forecasts, although, only one at a time. Check the top “readme” section on the script. Also, for the embedded images, I’m fairly certain that you’ll need the Textile plugin active on your instance.

Now that I know for certain what the weather is going to be like, I’m heading outside.