Get California Air Quality Using Ruby


Here’s a quick piece of code that will pull the air quality for any ZIP code in California using Ruby and Nokogiri. It uses the AirNow website, which provides this data for the state.

I have additional code on my running version that checks every hour and sends me an email if pollution gets to a certain point.

Pretty handy. Now when I see it’s hazy outside I can know just how bad the pollution really is (if it’s that bad I’ll receive an email).

The next version of this I’m going to make into a web service that receives text messages, so I’ll just text whenever I’m curious and see what the current quality is.


  1. Nokogiri is a godsend.

  2. Follow me on GitHub here.

Related posts: