#!/usr/bin/python # Created 4/8/09 by Daedalus # http://fublag.wordpress.com # actaeus@gmail.com import urllib, httplib, sys def main(): while 1: query=raw_input("> ") query=urllib.urlencode({'q':query}) start='

' end='' google=httplib.HTTPConnection("www.google.com") google.request("GET","/search?"+query) search=google.getresponse() data=search.read() if data.find(start)==-1: print "Google Calculator results not found." else: begin=data.index(start) result=data[begin+len(start):begin+data[begin:].index(end)] result = result.replace(" ",",").replace(" × 10","E").replace("","").replace("\xa0",",") print result if __name__ == "__main__": main()