I want to get google search results with python, so far I have the following script, which I learned from this post:
import urllib2
from bs4 import BeautifulSoup
import lxml
import sqlite3
import urllib
import json
def showSome(searchFor):
query = urllib.urlencode({'q':searchFor})
url = 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&%s'%query
searchResponse = urllib.urlopen(url)
searchResults = searchResponse.read()
results = json.loads(searchResults)
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']
showSome("site:www.hitmeister.de/shops/")
It shows me 4380 results, when I search for the same query using browser, it gives me about 6650 results, how can I extract all results from google? And also this gives me top 4 results, how can I fetch all results?