I am writting a program to select a term like "Pony" then search google with that term, then obtain the number of search results there are & the time the search took.
But I have a problem:
I am unsure if I have the correct URL to search google for a term. I have been using the URL...
http://www.google.com/search?q="search term goes here"
But this URL doesn't work WHEN I try to retrieve the HTML source code so I can parse for the search result data.
If you place this URL in a browser, it will work, BUT if you use this link inside a program(I have tried in Python & Java) I get an IOException(in java) & IOError (in python).
So my question is...does google maybe stop programs from querying their engine like this so they dont get their search results stolen(another engine may piggy back off google instead of coming up with their own search algorithms)
OR
is there a proper google URL that I dont know about?
To see that it doesn't work you can run this python code & you will see that the IOError gets thrown:
import urllib2def get_source(URL): """ Retrieve & return HTML source code from website URL """ try: source_buffer = urllib2.urlopen(URL) source_code = source_buffer.read() source_buffer.close() print source_code except IOError: print """ 'get_source()' Function Failed: Reasons could be: - Invalid URL name OR - HTML protocol message transfer failure; Internet Connection does not exist.""" return Noneget_source( "http://www.google.com/search?q='pony'" )