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


Python Client.search方法代码示例

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


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

示例1: Yelp

# 需要导入模块: from yelp.client import Client [as 别名]
# 或者: from yelp.client.Client import search [as 别名]
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,代码行数:34,代码来源:get_yelp.py

示例2: yelp

# 需要导入模块: from yelp.client import Client [as 别名]
# 或者: from yelp.client.Client import search [as 别名]
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,代码行数:44,代码来源:hopscotch.py

示例3: api_callee

# 需要导入模块: from yelp.client import Client [as 别名]
# 或者: from yelp.client.Client import search [as 别名]
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,代码行数:56,代码来源:lambda_function.py

示例4: fetchCoffeeBusinesses

# 需要导入模块: from yelp.client import Client [as 别名]
# 或者: from yelp.client.Client import search [as 别名]
    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,代码行数:15,代码来源:yelp_client.py

示例5: yelpsearchapi_by_location

# 需要导入模块: from yelp.client import Client [as 别名]
# 或者: from yelp.client.Client import search [as 别名]
def yelpsearchapi_by_location(loc):
	DEFAULT_LOCATION = loc
	CREDENTIALS_PATH = 'static/credentials.json'
	RADIUS_FILTER_METERS = 1000
	NEAREST_SORT_OPTION = 1
	LIMIT = 5

	# read api keys credentials
	with io.open(CREDENTIALS_PATH) as cred:
		creds = json.load(cred)
		auth = Oauth1Authenticator(**creds)
		client = Client(auth)
    # enter parameters
    	params = { 'category_filter': 'bars',
    			   'radius_filter': RADIUS_FILTER_METERS,
    			   'sort': NEAREST_SORT_OPTION,
    			   'limit': LIMIT }

	if loc:
		response = client.search(loc, **params)
	else:
		response = client.search(DEFAULT_LOCATION, **params)

	return response
开发者ID:Somtida,项目名称:DecideR,代码行数:26,代码来源:app.py

示例6: search_yelp

# 需要导入模块: from yelp.client import Client [as 别名]
# 或者: from yelp.client.Client import search [as 别名]
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,代码行数:18,代码来源:routes.py

示例7: get

# 需要导入模块: from yelp.client import Client [as 别名]
# 或者: from yelp.client.Client import search [as 别名]
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,代码行数:19,代码来源:yelp_api.py

示例8: YelpService

# 需要导入模块: from yelp.client import Client [as 别名]
# 或者: from yelp.client.Client import search [as 别名]
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,代码行数:48,代码来源:services.py

示例9: get_businesses_from_yelp

# 需要导入模块: from yelp.client import Client [as 别名]
# 或者: from yelp.client.Client import search [as 别名]
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,代码行数:45,代码来源:local.py

示例10: yelp

# 需要导入模块: from yelp.client import Client [as 别名]
# 或者: from yelp.client.Client import search [as 别名]
 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,代码行数:23,代码来源:engine.py

示例11: yelp_search_resturants_general

# 需要导入模块: from yelp.client import Client [as 别名]
# 或者: from yelp.client.Client import search [as 别名]
    def yelp_search_resturants_general(self, city, state, radius):

         cityState = city + ',' + state

         auth = Oauth1Authenticator(
                 consumer_key= 'bM0VPHWh91R0g46amxYbnA',
                 consumer_secret='l-p2JF_V2BZSsNWGPRT7QywfoGE',
                 token='rD8K96AXRAxiwI_R_mQwwdMUwb65Ctt_',
                 token_secret= 'ugp2wQ8Pb4tcV0Qc8pc23MlkvLw'
                 )

         client = Client(auth)
         print "My client is authenticated" + str(client)
         params = {
                 'term': 'restaurants',
                 'radius_filter': str(int(radius) * 1609),
                 'sort': '0',
                 'limit':'20'
                 }

         data = client.search(cityState, **params)
         return data
开发者ID:geocas38,项目名称:csgangstas,代码行数:24,代码来源:main.py

示例12: yelp_search_attractions

# 需要导入模块: from yelp.client import Client [as 别名]
# 或者: from yelp.client.Client import search [as 别名]
    def yelp_search_attractions(self, city, state, radius):

        cityState = city + ',' + state

        #Authentication keys for yelp
        auth = Oauth1Authenticator(
            consumer_key= 'bM0VPHWh91R0g46amxYbnA',
            consumer_secret='l-p2JF_V2BZSsNWGPRT7QywfoGE',
            token='rD8K96AXRAxiwI_R_mQwwdMUwb65Ctt_',
            token_secret= 'ugp2wQ8Pb4tcV0Qc8pc23MlkvLw'
                )
        client = Client(auth)

        params = {
            'category_filter': 'landmarks,museums,beaches',
            'radius_filter': str(int(radius) * 1609),
            'sort': '0',
            'limit': '20'
            }

        data = client.search(cityState, **params)
        return data
开发者ID:geocas38,项目名称:csgangstas,代码行数:24,代码来源:main.py

示例13: get_restaurants

# 需要导入模块: from yelp.client import Client [as 别名]
# 或者: from yelp.client.Client import search [as 别名]
def get_restaurants(city, offset):
    """
    Returns API response from Yelp API call to get restaurants for a city, with the results offset.

    Note that Yelp only returns 20 results each time, which is why we need to offset if we want
    the next Nth results.
    """

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

    # Set term as restaurant to get restaurants for results
    # Need to pass in offset, so Yelp knows how much to offset by
    params = {
        'term': 'restaurant',
        'offset': offset
    }

    return client.search(city, **params)
开发者ID:ashleyhsia0,项目名称:breadcrumbs,代码行数:24,代码来源:yelp_api_call.py

示例14: API_adapter

# 需要导入模块: from yelp.client import Client [as 别名]
# 或者: from yelp.client.Client import search [as 别名]
class API_adapter(object):

    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)

    def get_restaurant(self, location, category_filter=None):
        params = {
            'term': 'food',
            'location': location,
            'cc' : 'US'
        }
        if category_filter:
            params['category_filter'] = category_filter

        restaurant = self.client.search(**params)
        return restaurant.businesses
开发者ID:1064no1carry,项目名称:FoodChasing_Web,代码行数:26,代码来源:api_adapter.py

示例15: get_yelp

# 需要导入模块: from yelp.client import Client [as 别名]
# 或者: from yelp.client.Client import search [as 别名]
def get_yelp(city, job):
    res = []

    with open('yelp.json') as cred:
        creds = load(cred)
        auth = Oauth1Authenticator(**creds)
        client = Client(auth)

    results = client.search(city, **{
        'term': job,
        'lang': 'fr',
        'sort': 2
    }).businesses

    for result in results:
        res.append({
            "name": result.name,
            "rating": result.rating,
            "longitude": result.location.coordinate.longitude,
            "latitude": result.location.coordinate.latitude,
            "street": result.location.address
        })

    return res
开发者ID:fhacktory,项目名称:Pokemon69,代码行数:26,代码来源:api.py


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