Simple command-line wunderground weather fetcher

I like wunderground a lot for weather. They’re data-centric and not interested in peddling you with news or advertisements. While I was customizing my shell aliases a few days ago, I realized that it would be nifty to have a very simple command-line weather fetcher. But after spending some twenty minutes looking at a sample RSS feed and parsers, I couldn’t find any off-the-shelf tools to pretty-print the XML and I didn’t want to bother with the parsing myself.

I pretty much left it at that. Except a few days later, a friend suggested wunderground’s API. I figured it wouldn’t hurt to sign up (it’s free). After a short visit to the documentation and admiring their simple yet rich JSON API, I was totally nerd-sniped into writing a command-line weather fetcher in python.

But generic parsing of the relevant response keys wasn’t enough. I decided that the fetcher must also render the icon representing the current weather in the console (which is easy with fabulous).

A screenshot of the result (for two different locations):

wunder.py source: https://gist.github.com/3243785

Unfortunately, I can’t distribute my wunderground API key, as I’m capped to a certain number of requests per day (500 — plenty for my uses, not so much if random people start using it). But as I said, it’s free to sign up for an account to get one.

  1. dujoducom said: Nice! A few months ago I was trying to find a weather service with an API that actually gave bitmap data for radar images, etc. but couldn’t find anything. I ended up just using the “NatLoop.gif” from here: radar.weather.gov/ridge…
  2. tonybaldwin said: doh, installed fabulous. Now I see the icon, too.
  3. mintwater posted this
blog comments powered by Disqus