Google allegedly no longer supports this api with the latest version of python. I made an error report, but never heard back.

Preface: There is a computer programming language that is oriented towards new developers. That language is called Python. It is available for most every platform. (i.e. MSWindows, OS/X, BSD, Linux and etc.)  Though there are no fancy graphics in what was done in this project, you could surely add that feature. Just wanted to show a bare bones project that anyone could use to start with.

One of the reasons I like to do page scraping is to get the data I need without having to take time to use a web browser such as Firefox and or a newsreader to get the specific data I need. Letting the computer get the data for me and making a summary file of the data I need is therefore letting the computer be my secretary and or research assistant.

Have been doing some page scraping, but i was not able to get the weather from their (Google) site. Then read they have it sort of hidden. Was able to get a page of the xml they use to show the data. Could not find an easy way to page scrape it. Aha. then found a short piece of code of how to use the Google api! We then modified that code for our needs.

The xml (abridged) version (using http://www.google.com//ig/api?weather=huntsville) :

See picture.

So then it was a matter of just plugging in variables. Almost cut and paste. Anything in single quotes was extracted from the xml sort of.  I also make it so that you did not have to redo the code of a different location. This also could be done in a gui environment, but for simplicities sake that part was not included.

import sys
import  pywapi
import string

google_result = pywapi.get_weather_from_google(sys.argv[1])

print "\nThe weather report for " + sys.argv[1] + "  on " + google_result['forecast_information']['current_date_time'] + " in: " +  google_result['forecast_information']['city'] + " \n"

print "Sky condition: " + string.lower(google_result['current_conditions']['condition'])
print "Temperature: " + google_result['current_conditions']['temp_f'] + "F"

print google_result['current_conditions']['humidity']

print google_result['current_conditions']['wind_condition']

usage: python weather.py zipcode or python weather.py "city state"

$ python weather.py 10001

The weather report for 10001  on 2011-11-18 21:51:00 +0000 in: New York, NY

Sky condition: clear
Temperature: 44F
Humidity: 37%
Wind: N at 0 mph

$ _

Note: I had to install the pywapi
$ sudo apt-get install pywapi

This was a lot easier than page scraping. This is one of only a zillion examples you can use from Google code. Anyway enjoy.

Pywapi is not in the debian repos: https://launchpad.net/python-weather-api/+download
Is there a downloadable file that can be installed on a custom build device? I've been looking for a program that will help me search through files easier. If possible can it be controlled with the users voice?
<p>There is no generic install for all devices. You probably just have to do a web search.. As for voice recognition, it will depend on the platform you are using. </p>

About This Instructable




Bio: computoman.blogspot.com Bytesize articles instead of a trilogy in one post.
More by Computothought:Coffeepot meals Easy sun hat Easy cakes and pies. 
Add instructable to: