Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As far as I can tell, there is no API available as of yet, and neither is there a working implementation of a method for extracting data from Google Insights. However, I have found a solution to my (slightly more specific) problem, which could really just be solved by knowing how many times certain terms are searched for.</p> <p>This can be done by interfacing with the Google Suggest protocol for webbrowser search bars. When you give it a word, it returns a list of suggested phrases as well as the number of times each phase has been searched (I'm not sure about the time unit, presumably in the last year). </p> <p>Here is some python code for doing this, slightly adapted from code by odewahn1 at <a href="http://answers.oreilly.com/topic/1526-how-to-use-the-google-suggest-api-to-come-up-with-topics-for-answers/" rel="noreferrer">O'reilly Answers</a> and working on Python 2.6 and lower:</p> <pre><code>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 THE BASE QUERY HERE base_query = "" #This is the base query base_query += "%s" alphabet = "abcdefghijklmnopqrstuvwxyz" for letter in alphabet: q = base_query % letter; query = urllib.urlencode({'q' : q}) url = "http://google.com/complete/search?output=toolbar&amp;%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]) </code></pre> <p>This at least solves the problem in part, but unfortunately it is still difficult to reliably obtain the number of searches for any specific word or phrase and impossible to obtain the search history of different phrases.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload