Starting to be a bit of a grey area here...
From the Google 'terms of service':
http://www.google.com/terms_of_service.htmlSome assorted bits:
"The Google Services are made available for your personal, non-commercial use only"
"You may not take the results from a Google search and reformat and display them"
"If you want to make commercial use of the Google Services, you must enter into an agreement with Google to do so in advance."
They seem to explicitely forbit you for harvesting & reformatting their results. Now, they also offer the Google API service which does enable your program to query Google directly. There are a bunch of limitations to that service as well, though:
It requires you to register an account with Google, requires a license key, and limits you to 1,000 queries a day.
They also have some bits about how it is not OK to send automated queries of any sort to Google's system without express permission in advance by Google, and how it's not OK to perform meta-searches either.
Now, technically you can make all of it work, and depending on the scale of the # of queries they may not care a whole lot about what you're doing, just be aware that they have legal options on their side if you
do show up on their radar. Other search engines like Altavista appear to have similar restrictions.