• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python client.Client类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get_random_bar_coords

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,代码行数:29,代码来源:yelp_utils.py


示例2: call_yelp

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,代码行数:29,代码来源:midpt_yelp.py


示例3: Yelp

def Yelp(command, yelp_authkeys):

    lowerCom = command.lower()

    searchType = re.findall(r'yelp (.*?) in', lowerCom, re.DOTALL)
    searchKey=""
    for t in searchType:
        searchKey+=t
    searchType=searchKey	
    params = {
            'term' : searchType
            }

    keyword = 'in '
    before_key, keyword, after_key = lowerCom.partition(keyword)
    location = after_key

    auth = Oauth1Authenticator(
        consumer_key = yelp_authkeys["CONSUMER_KEY"], 
        consumer_secret= yelp_authkeys["CONSUMER_SECRET"],
        token = yelp_authkeys["TOKEN"],
        token_secret = yelp_authkeys["TOKEN_SECRET"]
    )

    client = Client(auth)

    response = client.search(location, **params)

    out =""
    for x in range(0,3):
        out += str(x+1) + ". " + str(response.businesses[x].name) + "\n Address: " + str(response.businesses[x].location.display_address).strip('[]').replace("'","").replace(",","") + "\n Ratings: " + str(response.businesses[x].rating) + " with " + str(response.businesses[x].review_count) + " Reviews \n Phone: " + str(response.businesses[x].display_phone) + "\n"
    return(out)
开发者ID:jcallin,项目名称:eSeMeS,代码行数:32,代码来源:get_yelp.py


示例4: post_detail

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,代码行数:55,代码来源:views.py


示例5: api_callee

def api_callee(event, context):
    # read API keys
    with io.open('config_secret.json') as cred:
        creds = json.load(cred)
        auth = Oauth1Authenticator(**creds)
        client = Client(auth)

    params = {
        'term': event['item'],
        'lang': 'en',
        'limit': 5
    }

    #print event['item']
    #print event['location']
    response = client.search(event['location'], **params)
    #print response
    placesYelp = ""
    #print response.businesses[0]
    if response.businesses == None:
        placesYelp = 'jankiap50_error_yelp'
    elif len(response.businesses) == 0:
        placesYelp = 'jankiap50'
    else:
        placesYelp = str(response.businesses[0].name) +'@'+ \
                    str(response.businesses[0].mobile_url.partition("?")[0]) +'@' + \
                    str(response.businesses[0].image_url) +'@' + \
                    str(response.businesses[0].rating) +'@' + \
                    str(response.businesses[0].display_phone)+'@' + \
                    str(response.businesses[1].name)+'@' + \
                    str(response.businesses[1].mobile_url.partition("?")[0])+'@' + \
                    str(response.businesses[1].image_url) +'@' + \
                    str(response.businesses[1].rating)+'@' + \
                    str(response.businesses[1].display_phone)+'@' + \
                    str(response.businesses[2].name)+'@' + \
                    str(response.businesses[2].mobile_url.partition("?")[0])+'@'+ \
                    str(response.businesses[2].image_url) +'@' + \
                    str(response.businesses[2].rating)+'@' + \
                    str(response.businesses[2].display_phone)+'@' + \
                    str(response.businesses[3].name)+'@' + \
                    str(response.businesses[3].mobile_url.partition("?")[0])+'@' + \
                    str(response.businesses[3].image_url) +'@' + \
                    str(response.businesses[3].rating)+'@' + \
                    str(response.businesses[3].display_phone)+'@' + \
                    str(response.businesses[4].name)+'@' + \
                    str(response.businesses[4].mobile_url.partition("?")[0])+'@'+ \
                    str(response.businesses[4].image_url) +'@' + \
                    str(response.businesses[4].rating)+'@' + \
                    str(response.businesses[4].display_phone)+'@'

    #return response.businesses[0].name, response.businesses[0].url.partition("?")[0], response.businesses[0].rating, response.businesses[0].display_phone
    #print str(placesYelp)
    result=placesYelp.encode('ascii', 'ignore')
    return result
开发者ID:ruchir594,项目名称:yelpbot,代码行数:54,代码来源:lambda_function.py


示例6: getRestaurants

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,代码行数:11,代码来源:server.py


示例7: fetchCoffeeBusinesses

    def fetchCoffeeBusinesses(self):  
        with io.open(self.yelp_auth_path) as auth_file:
            creds = json.load(auth_file)
            auth = Oauth1Authenticator(**creds)
            client = Client(auth)

        params = {
            'term': 'coffee',
            'lang': 'en'
        }
        
        coffee_shops = client.search('San Francisco', **params)
        return coffee_shops.businesses
开发者ID:katchengli,项目名称:MapDisplay,代码行数:13,代码来源:yelp_client.py


示例8: get_total_ratings

def get_total_ratings(x):
    # authenticate the api
    auth = Oauth1Authenticator(
        consumer_key='d8eoj4KNoPqOqE_RN9871Q',
        consumer_secret='pGVDNEGSaH8Kv-WZ8ba5v02IjCo',
        token='S-SfyVte5G0nCkTmbydWRtxlheNXCEnG',
        token_secret='Y_UViE9LthLQqW7_ht8U8V_F6aE'
    )
    client = Client(auth)

    # return the total number of ratings for a restaurant
    total_ratings = client.get_business(x)
    total_ratings = total_ratings.business.review_count
    return total_ratings
开发者ID:wsharif,项目名称:yelp_hackathon_2016,代码行数:14,代码来源:restaurant_stats.py


示例9: get_results

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,代码行数:15,代码来源:searchtest.py


示例10: Add_nodes

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,代码行数:48,代码来源:Get_Data.py


示例11: search_yelp

def search_yelp(nouns):
  auth = Oauth1Authenticator(
    consumer_key=environ.get('YELP_CONSUMER_KEY'),
    consumer_secret=environ.get('YELP_CONSUMER_SECRET'),
    token=environ.get('YELP_TOKEN'),
    token_secret=environ.get('YELP_TOKEN_SECRET')
  )

  terms = reduce(lambda prev, curr: prev + ' ' + curr, nouns, ''),
  print terms
  client = Client(auth)
  return client.search('New York, NY', **{
    'term': nouns[0],
    'limit': 3,
    'category_filter': 'restaurants'
  });
开发者ID:sherodtaylor,项目名称:goodfoodbot,代码行数:16,代码来源:routes.py


示例12: get

def get(location, term):
	print('in yelp_api.get, with term: ', term)
	params = {
		'location': location,
		'term': term,
	}
	auth = Oauth1Authenticator(**settings.YELP_CONFIG)
	client = Client(auth)
	response = client.search(**params)
	total_results = response.total
	businesses = [business for business in response.businesses]
	average_rating = sum([business.rating for business in businesses])/len(businesses)
	return {
		'total': total_results,
		'selected_businesses_count': len(businesses),
		'average_rating': average_rating,
	}
开发者ID:Janteby1,项目名称:realtor,代码行数:17,代码来源:yelp_api.py


示例13: YelpService

class YelpService(object):

    def __init__(self):
        auth = Oauth1Authenticator(
            consumer_key="uz2Sv5gO6dwlnjRv3BqzwA",
            consumer_secret="VhgG3IucBO_eTheOlWzrVuuVjbU",
            token="bN1HD9FSDGqUWjzxbIkho_N1muVe0xcA",
            token_secret="hEdALK5D2gCI9-H3GwGKAw1jEYo"
        )

        self.client = Client(auth)

        self._business_cache = {}

    def get_location(self, yelp_id):
        """
        Get the location of a yelp business
        """
        business = self._get_business(yelp_id)
        return business.location.coordinate

    def get_name(self, yelp_id):
        """
        Get the name of a location
        """
        business = self._get_business(yelp_id)
        return business.name

    def get_url(self, yelp_id):
        """
        Get the url to the yelp side of a business
        """
        business = self._get_business(yelp_id)
        return business.url

    def _get_business(self, yelp_id):
        if yelp_id in self._business_cache:
            return self._business_cache[yelp_id]
        else:
            response = self.client.get_business(yelp_id)
            self._business_cache[yelp_id] = response.business
            return response.business

    def search(self, query, location):
        response = self.client.search(location=location, term=query)
        return response.businesses
开发者ID:fechu,项目名称:COS448,代码行数:46,代码来源:services.py


示例14: __init__

 def __init__(self):
     auth = Oauth1Authenticator(
             consumer_key= 'NqKErS1dFKKwfxlc5KpB0Q',
             consumer_secret= 'BzO_xc7Jge-B5YeysLuLi-WkiHE',
             token= '72CDWmpOaC8LEVgjY1bZVQgyX4v3v8fx',
             token_secret='yLfQC1-Vr_B5mpuqKtidnK_gnbo'
             )
     self.client = Client(auth)
开发者ID:daoanhnhat1995,项目名称:CS-4392-Keep-It-Fresh,代码行数:8,代码来源:yelp_client.py


示例15: get_businesses_from_yelp

def get_businesses_from_yelp(location_string):
    """ Search Yelp through API for knitting/yarn, save results to objects

    location_string: the user location string
    :return: list of YelpBusiness objects for input city
    """

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

    yelp_knitting_category_alias = 'knittingsupplies'

    params = {
        'category_filter': yelp_knitting_category_alias
    }

    yelp_results = client.search(location_string, **params)

    list_of_biz = []

    for business in yelp_results.businesses:
        biz_name = business.name
        biz_addr = business.location.display_address
        biz_city = business.location.city
        biz_lat = business.location.coordinate.latitude
        biz_long = business.location.coordinate.longitude
        biz_url = business.url
        biz_closed = business.is_closed

        # exclude businesses that are closed
        if biz_closed == False:
            new_biz = YelpBusiness(biz_name=biz_name,
                                   biz_addr=biz_addr[0],
                                   biz_city=biz_city,
                                   biz_lat=biz_lat,
                                   biz_long=biz_long,
                                   biz_url=biz_url)
            list_of_biz.append(new_biz)

    return list_of_biz
开发者ID:karayount,项目名称:commuKNITty,代码行数:43,代码来源:local.py


示例16: __init__

 def __init__(self):
     '''
     Load Oauth keys
     '''
     _path_ = os.path.abspath(os.path.dirname(sys.argv[0]))
     _path_ = '/'.join([_path_,'web_app/api_adapter/config_secret.json'])
     cred = io.open(_path_)
     cred = json.load(cred)  
     auth = Oauth1Authenticator(**cred)
     self.client = Client(auth)
开发者ID:1064no1carry,项目名称:FoodChasing_Web,代码行数:10,代码来源:api_adapter.py


示例17: yelp

def yelp(loc, c, paramsA, paramsB):
    print "YELP"
    auth = Oauth1Authenticator(
        consumer_key="Q7OyV59ytZdO-zuAo3Rl0g",
        consumer_secret="xNOuCM0FhUthxpA8RFiQgEPtFaM",
        token="EE_wX2qYssWNzSLL65gFCg9ciTbf1sEL",
        token_secret="gHEEbPgA66UVFAC3bmmehi6kY3I"
    )
    
    client = Client(auth)
    print "YELPC"
    print c
    if(c == 1 or c == '1'):
        print 1111111111111111111111111111111111111111
#        params1 = {
#            'sort': '2',
#            #'sort': '1',
#            'term': 'food',
#            'lang': 'en',
#            #'radius_filter': '10'
#        }
       # print "YELP1"
        response = client.search(loc, **paramsA)
    elif(c == 2 or c == '2'):
        print 222222222222222222222222222222222222222
#        params2 = {
#            'sort': '2',
#            #'sort': '1',
#            'term': 'fun',
#            'lang': 'en',
#            #'radius_filter': '10'
#        }
        response = client.search(loc, **paramsB)

    #print mainlist
    print "YELPM"
    for i in range(10):
 
        mainlist.append(response.businesses[i].name)
        ratinglist.append(response.businesses[i].rating)
        citylist.append(response.businesses[i].location.city)
    print mainlist
开发者ID:sgunonu,项目名称:hopscotch,代码行数:42,代码来源:hopscotch.py


示例18: __init__

    def __init__(self):
        auth = Oauth1Authenticator(
            consumer_key="uz2Sv5gO6dwlnjRv3BqzwA",
            consumer_secret="VhgG3IucBO_eTheOlWzrVuuVjbU",
            token="bN1HD9FSDGqUWjzxbIkho_N1muVe0xcA",
            token_secret="hEdALK5D2gCI9-H3GwGKAw1jEYo"
        )

        self.client = Client(auth)

        self._business_cache = {}
开发者ID:fechu,项目名称:COS448,代码行数:11,代码来源:services.py


示例19: yelp

 def yelp(self, words):
     print("yelp")
     auth = Oauth1Authenticator(
         consumer_key=cf.get("yelp", "ConsumerKey"),
         consumer_secret=cf.get("yelp", "ConsumerSecret"),
         token=cf.get("yelp", "Token"),
         token_secret=cf.get("yelp", "TokenSecret"),
     )
     client = Client(auth)
     if "around me" or "near me" in words:
         print("yelp")
         params = {"term": "food"}
         response = client.search("Lawrence", **params)
     text = (
         "Some of the restaurants are "
         + response.businesses[0].name
         + " and "
         + response.businesses[1].name
     )
     print(text)
     return text
开发者ID:lordlabakdas,项目名称:MunchTron,代码行数:21,代码来源:engine.py


示例20: YelpClient

class YelpClient(object):

    def __init__(self):
        auth = Oauth1Authenticator(
                consumer_key= 'NqKErS1dFKKwfxlc5KpB0Q',
                consumer_secret= 'BzO_xc7Jge-B5YeysLuLi-WkiHE',
                token= '72CDWmpOaC8LEVgjY1bZVQgyX4v3v8fx',
                token_secret='yLfQC1-Vr_B5mpuqKtidnK_gnbo'
                )
        self.client = Client(auth)

    def search(self,params):
        return self.client.get_business(params)
开发者ID:daoanhnhat1995,项目名称:CS-4392-Keep-It-Fresh,代码行数:13,代码来源:yelp_client.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python encoding.recode_uri函数代码示例发布时间:2022-05-26
下一篇:
Python yedit.Yedit类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap