title: How can I get Google search results with Python 3?
body: <p>I am trying to write a Python 3 function that works like the following:</p>
  
  <pre><code>links = google_search('"done" "store"')
  for l in links: print(l)
  </code></pre>
  
  <p>The output should be a very long list, something like:</p>
  
  <pre><code>www.cnn.com/articles/done_with_sotres.html
  www.something.org/whatever?p=bla
  .
  .
  .
  </code></pre>
  
  <p>I found this suggestion, <a href="https://stackoverflow.com/questions/1657570/google-search-from-a-python-app">Google Search from a Python App</a>, but I seem to get only 4 urls in "hits", and I am unsure how to get the rest.
  any suggestion will be highly appreciated!</p>
  
  <p>EDIT: stupid me! I didn't put the implementation. anyway, it's the one described in the link:</p>
  
  <pre><code>def search(search_string):
    query = urllib.parse.urlencode({'q': search_string})
    url = 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&amp;%s' % query
    search_response = urllib.request.urlopen(url)
    search_results = search_response.read().decode("utf8")
    results = json.loads(search_results)
    data = results['responseData']
    print('Total results: %s' % data['cursor']['estimatedResultCount'])
    hits = data['results']
    print('Top %d hits:' % len(hits))
    for h in hits: print(' ', h['url'])
    print('For more results, see %s' % data['cursor']['moreResultsUrl'])
    return hits
  </code></pre>