http://blogoscoped.c...-08-17-n22.html
The API returns the top 10 suggestions for the given query, plus the number of times it was searched for.
I wrote a quick Python script that allows you to put in a phrase like "How do i ..." and then pull the top 10 results for each letter in the alphabet (i.e., "How do i a," "how do i b," ... "how do i z"). In its infinite wisdom, Google converts the letter into the most used word that starts with that letter. The output is sent to the screen, so you should redirect it into a file if you want to save the results.
from sgmllib import SGMLParser
import urllib2
import urllib
# Define the class that will parse the suggestion XML
class PullSuggestions(SGMLParser):
def reset(self):
SGMLParser.reset(self)
self.suggestions = []
self.queries = []
def start_suggestion(self, attrs):
for a in attrs:
if a[0] == 'data': self.suggestions.append(a[1])
def start_num_queries(self, attrs):
for a in attrs:
if a[0] == 'int': self.queries.append(a[1])
# -----------------------------------------------------------
# Enter your phrase here. Be sure to leave the %s at the end!
# -----------------------------------------------------------
base_query = "how do i %s" #This is the base query
alphabet = "abcdefghijklmnopqrstuvwxyz"
for letter in alphabet:
q = base_query % letter;
query = urllib.urlencode({'q' : q})
url = "http://google.com/complete/search?output=toolbar&%s" % query
res = urllib2.urlopen(url)
parser = PullSuggestions()
parser.feed(res.read())
parser.close()
for i in range(0,len(parser.suggestions)):
print "%s\t%s" % (parser.suggestions[i], parser.queries[i])
So, no more excuses: drop into your terminal, fire up Python, run this script, and start adding some Answers. The world cannot wait to learn how to delete a Facebook account, jailbreak an iPhone, become a vampire, or zest a lemon. Won't you please help these desperate, lemon-zesting-deficient people out?

Help






