def test_sample(self):
     query = GoogleSearchResults({
         "q": "Coffee",
         "location": "Austin,Texas"
     })
     results = query.get_json()
     self.assertEqual(results["local_results"][0]["title"],
                      "Houndstooth Coffee")
 def test_get_json(self):
     client = GoogleSearchResults({
         "q": "Coffee",
         "location": "Austin,Texas"
     })
     data = client.get_json()
     self.assertIsNotNone(data["local_results"][0]["title"])
     pp = pprint.PrettyPrinter(indent=2)
     pp.pprint(data)
Ejemplo n.º 3
0
def map_site_helper(url, link_list, count, iterations):
    if (count == iterations):
        return link_list
    new_url = url
    query = GoogleSearchResults({"q": url, "num": 20})
    json_results = query.get_json()
    print json_results
    for item in json_results["organic_results"]:
        new_url += " -" + item['link']
        link_list.append(item['link'])
    return map_site_helper(new_url, link_list, count + 1, iterations)
Ejemplo n.º 4
0
#!/usr/bin/env python3

#python test
import sys

from lib.google_search_results import GoogleSearchResults

params = {
    "q" : sys.argv[1],
    "num" : "1000",
    "location" : "Austin, Texas, United States",
    "hl" : "en",
    "gl" : "us",
    "google_domain" : "google.com",
    "api_key" : "",
}

query = GoogleSearchResults( params )
json_results = query.get_json()
#print( ">>>> {}".format(json_results['search_information']['query']) )
#print( ">>>> {}".format(json_results['search_information']['total_results']) )
#print( "" )

for r in json_results['organic_results']:
    #print( "{}. {}".format(r['position'],r['link']) )
    print( "{}".format(r['link']) )