forked from jp2810/Extension
/
google_custom_search_places.py
31 lines (27 loc) · 1.03 KB
/
google_custom_search_places.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#API_key='AIzaSyBdGY-23XisY8ZwOuvdnseGBbFIndd3oYs'
#engine_id='008016317575559464792:m0_rq_ajn8g'
import urllib2
import json
import pprint
class search:
def search_places(self,search_query):
#search_query = ' '.join(kw)
print "search query:" + search_query
search_query=search_query.replace(" ","+")
print "search query:" + search_query
#search_query="pune"
#data = urllib2.urlopen('https://www.googleapis.com/customsearch/v1?key=AIzaSyBdGY-23XisY8ZwOuvdnseGBbFIndd3oYs&cx=008016317575559464792:luzdbvjplgm&q='+search_query+'&highrange=1&start=1')
data = urllib2.urlopen('https://www.googleapis.com/customsearch/v1?key=AIzaSyBdGY-23XisY8ZwOuvdnseGBbFIndd3oYs&cx=008016317575559464792:luzdbvjplgm&q='+search_query+'&highrange=1&start=1')
data = json.load(data)
#pprint.PrettyPrinter(indent=4).pprint(data['items'][0])
try:
for item in data['items']:
print "\n\n"
print item['title']
print item['snippet']
print item['link']
except Exception:
pass
return data
#obj = search()
#obj.search_places("pune")