示例#1
0
def groceries():
    #BROOKLYN={'lat': 40.645244, 'lng': -73.9449975}
    BROOKLYN={'lat': 40.692, 'lng': -73.983}

    google_places = GooglePlaces(read_api_key())
    
    # You may prefer to use the text_search API, instead.
    query_result = google_places.radar_search(
            keyword='',
            lat_lng=BROOKLYN ,# keyword='Fish and Chips',
            radius=1850, types=[types.TYPE_GROCERY_OR_SUPERMARKET])


    pts = []
    for place in query_result.places:
        #print place.geo_location
        pts.append((place.geo_location['lng'], place.geo_location['lat']))

    return pts
示例#2
0
from __future__ import print_function
import simplejson as json
from googleplaces import GooglePlaces, types, lang
import pprint
import re

pp = pprint.PrettyPrinter(indent=4)

# api_key = 'AIzaSyAJ4-7cvzD1FXN2JisaRlTdF3RzfXRUE7o'
api_key = 'AIzaSyCOUNC03eGdEIlkOU6xDHoLeL1E-qb1qg8'
google_places = GooglePlaces(api_key)
# around paderborn
query_result = google_places.radar_search(lat_lng={'lat': 51.71905, 'lng': 8.75439}, keyword='bar', radius=1000)
# id Counter i
i = 1
for place in query_result.places[80:94]:
	# make a random token - for verification
	place.get_details()
	print (place.name)
	outputJson = place.details
	# pp.pprint(outputJson)
	print ('opening_hours' and 'close' and 'open' in str(outputJson))
	# lat = str(outputJson['geometry']['location']['lat'])
	# lng = str(outputJson['geometry']['location']['lng'])
	# # print(('open' in str(outputJson['opening_hours']['periods']))
	# print(lat)
	# print(lng)
	
示例#3
0
def search(param):
    YOUR_API_KEY = random.choice(rankeys)
    google_maps = GoogleMaps(YOUR_API_KEY)
    google_places = GooglePlaces(YOUR_API_KEY)
    ans = param + " restaurants."
    origins = param
    #origins = origins.decode('utf-8')
    prefix = "http://maps.googleapis.com/maps/api/geocode/json?address="
    location = param
    postfix = "&sensor=false"
    urlData = prefix + parse.quote(location.encode('UTF-8')) + postfix
    webUrl = urlopen(urlData)
    if (webUrl.getcode() == 200):
        data = webUrl.read().decode('utf-8')
        j = json.loads(data)
        try:
            lat1 = (j["results"][0]["geometry"]["location"]["lat"])
            lon1 = (j["results"][0]["geometry"]["location"]["lng"])
        except:
            lat1 = 33.5003192
            lon1 = 126.5278462
    try:
        query_result = google_places.radar_search(
            location=origins,
            radius=300,
            language='ko',
            keyword='restaurant',
            types=[types.TYPE_FOOD, types.TYPE_RESTAURANT])
    except:
        query_result = google_places.radar_search(
            location="제주창조경제혁신센터",
            radius=300,
            language='ko',
            keyword='restaurant',
            types=[types.TYPE_FOOD, types.TYPE_RESTAURANT])
    # If types param contains only 1 item the request to Google Places API
    # will be send as type param to fullfil:
    # http://googlegeodevelopers.blogspot.com.au/2016/02/changes-and-quality-improvements-in_16.html

    #if query_result.has_attributions:
    #    print(query_result.html_attributions)
    rst = ""
    result = {}
    data = []
    ans = query_result.places
    for ind, place in enumerate(ans):
        place.get_details()
        destination = place.geo_location
        if ind > 9:
            break
        content = {}
        # rst+=("####["+str(ind+1)+": "+place.name+"]##")
        content['name'] = (str(ind + 1) + ": " + place.name)
        distance = distancer(lon1, lat1, float(destination['lng']),
                             float(destination['lat'])) * 1000
        # rst += "##dstance: " +str(round(distance,2))+"m"
        content['distance'] = str(round(distance, 2)) + "m"
        # rst +="##phone: "+str(place.local_phone_number)
        content['phone'] = str(place.local_phone_number)
        # rst +="##route: maps.google.com/?daddr="+str(destination['lat'])+","+str(destination['lng'])
        # content['find']="http://maps.google.com/?daddr="+str(destination['lat'])+","+str(destination['lng'])
        # rst += "##address: " + str(place.formatted_address)
        content['addr'] = str(place.formatted_address)
        content['lat'] = str(destination['lat'])
        content['lng'] = str(destination['lng'])
        data.append(content)
    result['data'] = data
    result['status'] = len(ans)
    return result
示例#4
0
import googleplaces
from googleplaces import GooglePlaces, types, lang

AUTH_KEY = "AIzaSyCPrWFxTwfbV1LJSMPyEnroNh_Ezb2KEhI"

url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?&key=" + AUTH_KEY + "&location"
google_places = GooglePlaces(AUTH_KEY)
#google_places = GooglePlaces(AUTH_KEY)
query_result = google_places.radar_search(location='Seoul, Korea',
                                          radius=50000,
                                          keyword='cafe',
                                          type='cafe')

if query_result.has_attributions:
    print(query_result.html_attributions)

print(query_result.place_id)
#for place in query_result.place_id:
#	print(place.geo_location)
#	print(place.place_id)
#	place.get_details()
#	print(place.details)
#	print(place.url) #local_phone_number, website,
示例#5
0
import sys
reload(sys)
sys.setdefaultencoding('utf-8')

from googleplaces import GooglePlaces, types, lang
import pandas as pd

API_KEY = 'AIzaSyCKxP9RqeiMwqU4lrS0WwNabD55fjs-XHE'

google_places = GooglePlaces(API_KEY)

#query_result = google_places.nearby_search(
#        location='หางดง', keyword='ATM หางดง',
#        radius=10000)
query_result = google_places.radar_search(keyword="ร้านอาหาร",
                                          location="เมืองเชียงใหม่",
                                          radius=10000)

if query_result.has_attributions:
    print(query_result.html_attributions)
'''
iMaxPlacesToFetch = 1000
iPlacesFetched = 0

res_list = []

while iPlacesFetched < iMaxPlacesToFetch:
    for place in query_result.places:
        place.get_details()
        if place.rating > 3:
            print('[%i] %s %s' % (iPlacesFetched, place.name, place.rating))