For whatever reason, there aren’t many examples on the net of Python code that can be used with the Google AJAX Search API. I’m not really sure why this is and perhaps I’m missing something, but for future reference here’s some sample python code.

{% codeblock %}{% codeblock %} #!/usr/bin/python import urllib import simplejson

query = urllib.urlencode({‘q’ : ‘damon cortesi’}) url = ‘http://ajax.googleapis.com/ajax/services/search/web?v=1.0&%s'
% (query) search_results = urllib.urlopen(url) json = simplejson.loads(search_results.read()) results = json[‘responseData’][‘results’] for i in results: print i[’title’] + “: " + i[‘url’] {% endcodeblock %}{% endcodeblock %}