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


Python YelpAPI.business_query方法代码示例

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


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

示例1: pprint

# 需要导入模块: from yelpapi import YelpAPI [as 别名]
# 或者: from yelpapi.YelpAPI import business_query [as 别名]
                                                                                       "query(transaction_type="
                                                                                       "'delivery', location='dallas, "
                                                                                       "tx')"))
response = yelp_api.transaction_search_query(transaction_type='delivery', location='dallas, tx')
pprint(response)
print('\n-------------------------------------------------------------------------\n')


"""
    Example business query.
    
    Business API: https://www.yelp.com/developers/documentation/v3/business
"""
print("***** business information for Amy's on 6th St. *****\n{}\n".format("yelp_api.business_query(id='amys-ice-"
                                                                           "creams-austin-3')"))
response = yelp_api.business_query(id='amys-ice-creams-austin-3')
pprint(response)
print('\n-------------------------------------------------------------------------\n')


"""
    Example reviews query.
    
    Reviews API: https://www.yelp.com/developers/documentation/v3/business_reviews
"""
print("***** selected reviews for Amy's on 6th St. *****\n{}\n".format("yelp_api.reviews_query(id='amys-ice-"
                                                                       "creams-austin-3')"))
response = yelp_api.reviews_query(id='amys-ice-creams-austin-3')
pprint(response)
print('\n-------------------------------------------------------------------------\n')
开发者ID:gfairchild,项目名称:yelpapi,代码行数:32,代码来源:examples.py

示例2: YelpAPI

# 需要导入模块: from yelpapi import YelpAPI [as 别名]
# 或者: from yelpapi.YelpAPI import business_query [as 别名]
from yelpapi import YelpAPI
from yelp_authentication import CONSUMER_KEY, CONSUMER_SECRET, TOKEN, TOKEN_SECRET

yelp_api = YelpAPI(CONSUMER_KEY, CONSUMER_SECRET, TOKEN, TOKEN_SECRET)

# Example business query. Look at
# http://www.yelp.com/developers/documentation/v2/business for more
# information.

print("***** selected reviews for Amy's on 6th St. *****")

business = yelp_api.business_query(id='amys-ice-creams-austin-3')

for review in business['reviews']:
    print('rating: {}\nexcerpt: {}\n'.format(review['rating'], review['excerpt']))

开发者ID:makoshark,项目名称:yelp-api-cdsw,代码行数:17,代码来源:yelp3.py

示例3: YelpAPI

# 需要导入模块: from yelpapi import YelpAPI [as 别名]
# 或者: from yelpapi.YelpAPI import business_query [as 别名]
from yelpapi import YelpAPI

yelp_api = YelpAPI('V4oXt-CDFMUXzPerVYXWnA', 'omnmWvy6KQNOSt1o9qD0YwMtKiQ', '_WuvOb1mMpmTdhuh9LwvyY_RQzsiLt3B', 'yAbsrRApeXzSIO_KK1dbDzbw0oA')

rating_list = open('try_againrating_list.csv', 'w')
writer = csv.writer(rating_list)
business_id_list = []
rating_list = []

with open('new_clean_master_list.csv', 'r') as original_csv_file:
    episodes = original_csv_file.read().split('\n')
    for index, episode in enumerate(episodes):
        episodes[index] = episodes[index].split(',')
        business_id = episodes[index][5]
        try:
            response = yelp_api.business_query(id=business_id)
            rating_list.append(response['rating'])
            print business_id, response['rating']
        except KeyError:
            rating_business_id_list.append(business_id)
            rating_list.append('KeyError')
            print "{0} Key Error".format(biz_id)
    time.sleep(.5)

# for business_id, rating in zip(business_id_list, rating_list):
#     writer.writerow((business_id, rating))


# while True:
#     print "This prints once every 5 seconds."
#     time.sleep(5)
开发者ID:mcriqui,项目名称:DDD,代码行数:33,代码来源:get_rating.py

示例4: YelpAPI

# 需要导入模块: from yelpapi import YelpAPI [as 别名]
# 或者: from yelpapi.YelpAPI import business_query [as 别名]
from yelpapi import YelpAPI
from pprint import pprint

yelp_api = YelpAPI('V4oXt-CDFMUXzPerVYXWnA', 'omnmWvy6KQNOSt1o9qD0YwMtKiQ', '_WuvOb1mMpmTdhuh9LwvyY_RQzsiLt3B', 'yAbsrRApeXzSIO_KK1dbDzbw0oA')

# response = yelp_api.business_query(id='oohhs-and-aahhs-washington')
# pprint(response)

# print response['rating']

# response = yelp_api.business_query(id='mac-and-ernies-roadside-eatery-tarpley')
# response = yelp_api.business_query(id="brints-diner-wichita")
try:
    response = yelp_api.business_query(id="pizza-palace-knoxville")
    print response['rating']
except KeyError:
    print "Key Error"

开发者ID:mcriqui,项目名称:DDD,代码行数:19,代码来源:yesyelpapi.py

示例5: __init__

# 需要导入模块: from yelpapi import YelpAPI [as 别名]
# 或者: from yelpapi.YelpAPI import business_query [as 别名]
class YelpQuery:

    def __init__(self):
        self.DEFAULT_TERM = 'dinner'
        self.DEFAULT_LOCATION = 'San Luis Obispo, CA'
        self.SEARCH_LIMIT = 3
        self.SEARCH_PATH = '/v2/search/'
        self.BUSINESS_PATH = '/v2/business/'

        self.CONSUMER_KEY = "0Ji9mpDmiH0rub9AvjtRhQ"
        self.CONSUMER_SECRET = "b7SZdC5XVqbo3SKvlK28bs12hrM"
        self.TOKEN = "DTNxH_G-2dF_PmiZzY7geQJnW5rcVWxu"
        self.TOKEN_SECRET = "dj-jziXREJcEf3vtmwWkqQFXu_8" 

    def connect(self):
        self.yelp_api = YelpAPI(self.CONSUMER_KEY, self.CONSUMER_SECRET, self.TOKEN, self.TOKEN_SECRET)

    def get_business(self, business_id, **kw_args):
        business_results = self.yelp_api.business_query(id=business_id, **kw_args)
        return businessResults

    def search(self, **kwargs):
        search_results = self.yelp_api.search_query(**kwargs)
        return search_results
    
    #get a valid restaurant 
    def getValidRestaurant(self, **kwargs):
        response = self.search(**kwargs)
        nameMatch = False
        result = None 
        i = 0
        while not nameMatch and i < 3 and i < len(response["businesses"]):
            business = response["businesses"][i]
            if business["name"].lower() == kwargs["term"].lower():
                nameMatch = True
                result = business
            i+=1
        
        if len(response["businesses"]) > 0:
                result = response["businesses"][0]
       
        return result

    def getExactFeatures(self, restaurantName, location, weight):
        featureDict = {}
        if location == "Arnold":
                location = "Arnold, CA"
        elif restaurantName == "G-Brothers Kettlecorn":
                restaurantName = "G Brothers"
        elif location == "Shell Beach" and "intock" in restaurantName:
                restaurantName = "F. McLintocks Saloon & Dining House"
                location = "Shell Beach, CA"
        

        yelpRestaurant = self.getValidRestaurant(term = restaurantName, location = location, limit = 3)
        if yelpRestaurant:
            rating = self.getExactRating(yelpRestaurant)
            reviewCount = self.getReviews(yelpRestaurant)
        else:
            rating = self.getExactRating({"rating" : 3.0, "review_count" : 21})
            reviewCount = self.getReviews({"rating": 3.0, "review_count" : 21})
         #the only restaurant for which this failed is Alphys. Hardcoding the vals from
         #Alphys Chateau Basque at http://www.yelp.com/biz/alphys-chateau-basque-pismo-beach-2
            print("No yelp info for %s in %s" % (restaurantName, location))
         
        for i in range(1, weight + 1):
            featureDict["rating%d" %i] = rating
            featureDict["reviewCount%d" %i] = reviewCount
                
        return featureDict 

    def getFeatures(self, restaurantName, location, weight):
        featureDict = {}
        if location == "Arnold":
                location = "Arnold, CA"
        elif restaurantName == "G-Brothers Kettlecorn":
                restaurantName = "G Brothers"
        elif location == "Shell Beach" and "intock" in restaurantName:
                restaurantName = "F. McLintocks Saloon & Dining House"
                location = "Shell Beach, CA"
        

        yelpRestaurant = self.getValidRestaurant(term = restaurantName, location = location, limit = 3)
        if yelpRestaurant:
            rating = self.getRating(yelpRestaurant)
            reviewCount = self.getReviews(yelpRestaurant)
        else:
            rating = self.getRating({"rating" : 3.0, "review_count" : 21})
            reviewCount = self.getRating({"rating": 3.0, "review_count" : 21})
         #the only restaurant for which this failed is Alphys. Hardcoding the vals from
         #Alphys Chateau Basque at http://www.yelp.com/biz/alphys-chateau-basque-pismo-beach-2
            print("No yelp info for %s in %s" % (restaurantName, location))
         
        for i in range(1, weight + 1):
            featureDict["rating%d" %i] = rating
            featureDict["reviewCount%d" %i] = reviewCount
                
        return featureDict

    def getReviews(self, restaurant):
#.........这里部分代码省略.........
开发者ID:JustinRoll,项目名称:project1,代码行数:103,代码来源:yelpQuery.py


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