当前位置: 首页>>代码示例>>Python>>正文


Python Client.search_by_coordinates方法代码示例

本文整理汇总了Python中yelp.client.Client.search_by_coordinates方法的典型用法代码示例。如果您正苦于以下问题:Python Client.search_by_coordinates方法的具体用法?Python Client.search_by_coordinates怎么用?Python Client.search_by_coordinates使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yelp.client.Client的用法示例。


在下文中一共展示了Client.search_by_coordinates方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: call_yelp

# 需要导入模块: from yelp.client import Client [as 别名]
# 或者: from yelp.client.Client import search_by_coordinates [as 别名]
def call_yelp(midlat,midlong,radius):
	auth = Oauth1Authenticator(
    		consumer_key='Qas4yX9C4dXU-rd6ABmPEA',
    		consumer_secret='5Rtb9Gm5KuwRHSevprdb450E37M',
    		token='xBq8GLMxtSbffTWPPXx7au7EUd2ed3MO',
    		token_secret='Nee0b14NkDO9uSX5cVsS7c4j6GQ'
	)
	print radius
	client = Client(auth)

	params = {
        	'term':'24 hour',
        	'sort':'0',
       		'radius_filter': str(radius) # 3 mi radius
	}

	#ex: response = client.search_by_coordinates(40.758895,-73.985131, **params)
	response = client.search_by_coordinates(float(midlat),float(midlong), **params)

	f = open('output_yelp.txt','w+')

	for i in range(0,len(response.businesses)):
        	#f.write(response.businesses[i].name)
        	#f.write(",")
       	 	f.write('%f' % response.businesses[i].location.coordinate.latitude)
        	f.write(",")
        	f.write('%f' % response.businesses[i].location.coordinate.longitude)
        	f.write("\n")
	f.close()
开发者ID:Sapphirine,项目名称:Safest-Route-Prediction-in-Urban-Areas,代码行数:31,代码来源:midpt_yelp.py

示例2: get_random_bar_coords

# 需要导入模块: from yelp.client import Client [as 别名]
# 或者: from yelp.client.Client import search_by_coordinates [as 别名]
def get_random_bar_coords(lat, lon, radius):
    mpm = 1609.34  # meters per mile
    config = json.load(open('conf.json', 'rb'))

    auth = Oauth1Authenticator(
        consumer_key=config['yelp']['consumer_key'],
        consumer_secret=config['yelp']['consumer_secret'],
        token=config['yelp']['token'],
        token_secret=config['yelp']['token_secret']
    )
    client = Client(auth)

    param_offset = lambda x: {
        'term': 'bars, All',
        'lang': 'en',
        'sort': 2,  # 2: only the top rated in the area
        'radius_filter': int(radius * mpm),
        'offset': x
    }

    bus_list = []
    for offset in [0, 20]:
        response = client.search_by_coordinates(lat, lon, **param_offset(offset))
        bus_list.extend(response.businesses)

    bar = random.choice(bus_list)
    while bar.name in ["Peter's Pub", "Hemingway's Cafe"]:  # Can we just
        bar = random.choice(bus_list)
    return bar.location.coordinate.latitude, bar.location.coordinate.longitude
开发者ID:digideskio,项目名称:barty_box,代码行数:31,代码来源:yelp_utils.py

示例3: post_detail

# 需要导入模块: from yelp.client import Client [as 别名]
# 或者: from yelp.client.Client import search_by_coordinates [as 别名]
def post_detail(request, photo_id):
    try:
        # get Flickr Post details
        post = FlickrPost.objects.get(pk=photo_id)
        context_dict['valid_post'] = True

        h = html.parser.HTMLParser()

        if not post.latitude or not post.longitude:
            photo = __get_flickr_post_info(photo_id)
            post.latitude = float(photo['location']['latitude'])
            post.longitude = float(photo['location']['longitude'])
            post.description = h.unescape(photo['description']['_content'])
            post.save()

        context_dict['post'] = post

        # get Yelp reviews for that location
        yelp = YelpClient.objects.get(pk=1)
        auth = Oauth1Authenticator(
            consumer_key=yelp.consumer_key,
            consumer_secret=yelp.consumer_secret,
            token=yelp.token,
            token_secret=yelp.token_secret
        )
        client = Client(auth)

        # get location that most closely matches the geolocation
        best_business = None
        alt_businesses = list()
        yelp_api_error = False

        try:
            response = client.search_by_coordinates(post.latitude, post.longitude)

            if response.businesses:
                best_business = response.businesses[0]

                if len(response.businesses) > 5:
                    alt_businesses = response.businesses[1:6]

                elif len(response.businesses) > 1:
                    alt_businesses = response.businesses[1:]

        except:
            yelp_api_error = True

        context_dict['yelp_api_error'] = yelp_api_error
        context_dict['best_business'] = best_business
        context_dict['alt_businesses'] = alt_businesses

    except FlickrPost.DoesNotExist:
        context_dict['valid_post'] = False

    return render(request, 'entree/post_detail.html', context_dict)
开发者ID:cs411-entree-app,项目名称:entree,代码行数:57,代码来源:views.py

示例4: getRestaurants

# 需要导入模块: from yelp.client import Client [as 别名]
# 或者: from yelp.client.Client import search_by_coordinates [as 别名]
def getRestaurants(latitude, longitude):
    client = Client(auth)

    params = {
        'term': 'food',
        'lang': 'en',
        'radius_filter': 10000
    }

    response = client.search_by_coordinates(latitude, longitude, **params)
    return response.businesses
开发者ID:PlanItOfficial,项目名称:main,代码行数:13,代码来源:server.py

示例5: get_results

# 需要导入模块: from yelp.client import Client [as 别名]
# 或者: from yelp.client.Client import search_by_coordinates [as 别名]
def get_results(params):

# read API keys
	with open('config_secret.json') as cred:
    	     creds = json.load(cred)
             auth = Oauth1Authenticator(**creds)
             client = Client(auth)

	request = client.search_by_coordinates("http://api.yelp.com/v2/search",params=params)
	
	#Transforms the JSON API response into a Python dictionary
	data = request.json()
	client.close()
	
	return data
开发者ID:rikinmathur,项目名称:EECS-6895-FINAL-PROJECT,代码行数:17,代码来源:searchtest.py

示例6: Add_nodes

# 需要导入模块: from yelp.client import Client [as 别名]
# 或者: from yelp.client.Client import search_by_coordinates [as 别名]
def Add_nodes(city_name = 'San_Francisco', buss_type = 'Restaurants' , number = 100):
    # Ussing the Yelp library for Yelp authentification and requesting info


    auth = Oauth1Authenticator(
        consumer_key="",
        consumer_secret="",
        token="",
        token_secret=""
    )
        
    client = Client(auth)

    buss_types = make_sure('buss_types')

    assert buss_type in buss_types.keys()

    locations = find_locations(city_name,number)

    if os.path.isfile('Data/{}_Data.json'.format(city_name)) == False:
        with open('Data/{}_Data.json'.format(city_name),'w') as f:
            geojson.dump({"type": "FeatureCollection","features": []}, f)

    with open('Data/{}_Data.json'.format(city_name)) as f:
            data = json.load(f)

    IDs = []    
    added = 0
    nodes_added = []

    for feature in [feature for feature in data['features'] if feature['geometry']['type'] == 'point']:
        IDs.append(feature['properties']['name'])

    for lat,long in locations:
        places = client.search_by_coordinates(lat, long, buss_type)
        for business in places.businesses:
            if business.name not in IDs:
                IDs.append(business.name)
                node = Node(business.name, business.location.coordinate.latitude, business.location.coordinate.longitude, business.rating,
                            buss_type, business.categories, business.image_url, city_name, comp_time = buss_types[buss_type]['durations'])
                data['features'].append(node.geo_interface())
                nodes_added.append(node)
                added += 1

    with open('Data/{}_Data.json'.format(city_name), 'w') as f:
        geojson.dump(data, f)

    return '{} nodes added'.format(added)
开发者ID:alegde,项目名称:OSTSP-Project,代码行数:50,代码来源:Get_Data.py

示例7: findScheduleOptions

# 需要导入模块: from yelp.client import Client [as 别名]
# 或者: from yelp.client.Client import search_by_coordinates [as 别名]
 def findScheduleOptions(self):
     self.options_list = []
     #Create a pair of activities for each of the combinations of one result from yelp and one from eventful
     for an_event in self.eventful_results:
         event_activity = Activity(an_event, "eventful")
         
         lat = an_event['latitude']  #
         lng = an_event['longitude']  #
         dining_activities = []
 
         auth = Oauth1Authenticator(consumer_key = "mvC1SY7wAUx_RPlVhG-fIw",consumer_secret = "vkqWVoowxsWkUu7KU0t2Pj3qY1k",token =  "syYEIdwvGt-uLGdgVmu9ZsQfE98CROe4", token_secret = "AQLQnKJA7VYw4XlVIMK7hYzSwDo") #
         client = Client(auth)  #
         
         print("yelp params", self.yelp_params)
         
         yelp_results = client.search_by_coordinates(lat, lng, **self.yelp_params)
         print(len(yelp_results.businesses))
         for j in range(len(yelp_results.businesses)):
             #print(location.businesses[j])
             #print(self.yelp_results.businesses[j])
             dining = Activity(yelp_results.businesses[j], "yelp")
             dining_activities.append(dining)
         self.options_list.append(EventAndDiningPair(event_activity, dining_activities))
开发者ID:nashau01,项目名称:Yelp_Eventful_App,代码行数:25,代码来源:ye_schedule.py

示例8: Client

# 需要导入模块: from yelp.client import Client [as 别名]
# 或者: from yelp.client.Client import search_by_coordinates [as 别名]
    consumer_secret=os.getenv('CONSUMER_SECRET'),
    token=os.getenv('TOKEN'),
    token_secret=os.getenv('TOKEN_SECRET')
)

client = Client(auth)
params = {
    'radius_filter': int(os.getenv('SEARCH_RADIUS')),
    # Need to offset as it only returns a max of 20 results.
    'offset': random.randint(0, int(os.getenv('SEARCH_OFFSET')))
}

with open('categories', 'r') as c:
    params['categories'] = c.read()
categories = params['categories'].replace('\n', ',')

response = client.search_by_coordinates(float(os.getenv('SEARCH_LAT')), float(os.getenv('SEARCH_LONG')), **params)
choices = response.businesses
choice = random.choice(choices)

# Trim query params from the URL
url = choice.url.split('?')[0]

with open('drivers', 'r') as f:
    drivers = f.readlines()

body = {'message': u'THE PEOPLE\'S LUNCH will be {}.\n{} has been chosen to drive.\n{}'
    .format(choice.name, random.choice(drivers).strip(), url), 'message_format': 'text', 'color': 'yellow',
        'notify': True}
requests.post(os.getenv('HIPCHAT_URL'), body)
开发者ID:vel0city,项目名称:lunch-picker,代码行数:32,代码来源:pick.py

示例9: Client

# 需要导入模块: from yelp.client import Client [as 别名]
# 或者: from yelp.client.Client import search_by_coordinates [as 别名]
    consumer_key='Qas4yX9C4dXU-rd6ABmPEA',
    consumer_secret='5Rtb9Gm5KuwRHSevprdb450E37M',
    token='xBq8GLMxtSbffTWPPXx7au7EUd2ed3MO',
    token_secret='Nee0b14NkDO9uSX5cVsS7c4j6GQ'
)

client = Client(auth)

params = {
	'term':'stores open 24 hours',
	'sort':'2',
	'radius_filter':'4828.03' # 3 mi radius
}

#response = client.search_by_coordinates(40.758895,-73.985131, **params)
response = client.search_by_coordinates(lat_input,long_input,**params)

#response = client.search('stores open 24 hours')

response.businesses

f = open('output_yelp.txt','w+')

for i in range(0,len(response.businesses)):
	f.write(response.businesses[i].name)
	f.write(",")
	f.write('%d' % response.businesses[i].location.coordinate.latitude)
	f.write(",")
	f.write('%d' % response.businesses[i].location.coordinate.longitude)
	f.write("\n")
开发者ID:Sapphirine,项目名称:Safest-Route-Prediction-in-Urban-Areas,代码行数:32,代码来源:24houryelp.py


注:本文中的yelp.client.Client.search_by_coordinates方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。