本文整理汇总了Python中yelpapi.YelpAPI类的典型用法代码示例。如果您正苦于以下问题:Python YelpAPI类的具体用法?Python YelpAPI怎么用?Python YelpAPI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了YelpAPI类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_info_from_api
def get_info_from_api(consumer_key, consumer_secret, token, token_secret, district, categories):
yelp_api = YelpAPI(consumer_key, consumer_secret, token, token_secret)
dictRest = {}
offset = [0]
for j in district:
for category in categories:
for k in offset:
search_results=yelp_api.search_query(term = category,location = j,offset = k,limit = 20)
list_Business=search_results["businesses"]
if len(list_Business) <> 0:
for i in list_Business:
if i["location"].has_key("coordinate") and i.has_key("categories"):
busi_id=i["id"]
if busi_id not in dictRest.keys():
busi_info = {}
busi_info["name"] = i["name"]
busi_info["categories"] = i["categories"]
busi_info["rating"] = i["rating"]
busi_info["url"] = i["url"]
busi_info["longitude"] = i["location"]["coordinate"]["longitude"]
busi_info["latitude"] = i["location"]["coordinate"]["latitude"]
dictRest[busi_id] = busi_info
return dictRest
开发者ID:SandeepReddyVanga,项目名称:TravelWorldSpunky,代码行数:28,代码来源:yelp.py
示例2: filter_by_category
def filter_by_category(user_cuisine):
# f = open('sample.json', 'w')
# for category in processed_rest_data:
# if "restaurants" in restaurant["parents"]:
# f = open('sample.json', 'r')
# contents = f.read()
# return json.loads(contents)
# for cuisine in cuisines:
# # params = get_search_parameters(cuisine)
# print cuisine
yelp_api = YelpAPI(CONSUMER_KEY, CONSUMER_SECRET, TOKEN, TOKEN_SECRET)
try:
print "trying %s....." % user_cuisine
results = yelp_api.search_query(category_filter=user_cuisine, location="San Francisco, CA", limit=20)
# results_string = json.dumps(results, indent=4)
# f.write(results_string+'\n')
# load_restaurants(results)
print "%s worked!" % user_cuisine
return results
except Exception, e:
print user_cuisine, 'failed'
print "error msg is:\n\n %s" % e
开发者ID:cristinamclarkin,项目名称:reservationtonight,代码行数:32,代码来源:yelp_api.py
示例3: nearby_yelp
def nearby_yelp(latitude, longitude):
#from https://github.com/gfairchild/yelpapi
#doc: http://www.yelp.com/developers/documentation/v2/search_api
#Sort mode: 0=Best matched (default), 1=Distance, 2=Highest Rated
yconsumer_key = '6IZDGF5Bck3MP6zU0lFgLQ'
yconsumer_secret = 'dZR4dJJpYUAETKH82yzv2nkXitM'
ytoken = 'YtSoZfbmiWxfLg87GGoLUsC_wcx8wUtO'
ytoken_secret = 'z9pDq7T0Pa_CwfQOMmF1XM4dhhQ'
max_yelp_radius = 10000
print YelpAPI(yconsumer_key, yconsumer_secret, ytoken, ytoken_secret)
yelp_api = YelpAPI(yconsumer_key, yconsumer_secret, ytoken, ytoken_secret)
llvar = str(latitude) + ',' + str(longitude)
search_results = yelp_api.search_query(ll=llvar, limit=20, sort=0, radius_filter=rdist)
#Make certain the farthest away places are still within your radius
for i in search_results.get('businesses'):
if i.get('distance') > max_yelp_radius:
index = search_results.get('businesses').index(i) #find the index of it
del search_results.get('businesses')[index]
return search_results
开发者ID:mrbhandari,项目名称:eazyhouz,代码行数:25,代码来源:social_data.py
示例4: main
def main():
consumer_key = "z5lwUGdh0deaEbvRhUwCKw"
consumer_secret = "Tq7QBqhKIKyNBlOEGYzJK0UrLHc"
token = "QwkD6OQ_h3zslXmnTyoitk5vZqhSt8pv"
token_secret = "95Oyv0QdB_v6ghyi87oe8AtPkBo"
yelp_api = YelpAPI(consumer_key, consumer_secret, token, token_secret)
args = {"term": "food", "location": "San Fransciso"}
response = yelp_api.search_query(term = "food", location="Menlo Park")
params = {"oauth_consumer_key": consumer_key,
"oauth_token": token,
"oauth_signature_method": "HMAC-SHA1",
"oauth_signature": token_secret,
"oauth_timestamp": int(time.time()),
"oauth_nonce": uuid.uuid4()
}
#url = "https://api.yelp.com/v2/search?term=food&location=San+Francisco"
#response = requests.get(url, params=params)
rand = random.randint(0,len(response['businesses']))
while rand < 4:
if response['businesses'][rand]['rating'] >= 4:
break
else:
rand = random.randint(0,len(response['businesses']))
rec_rest = {'restaurant': response['businesses'][rand]['name'],
'rating': response['businesses'][rand]['rating']}
for i in range(len(response['businesses'])):
if response['businesses'][i]['rating'] >= 4:
print({'restaurant': response['businesses'][i]['name'],
'rating': response['businesses'][i]['rating']})
else:
pass
print('\n',rec_rest,sep='')
开发者ID:amalhot5,项目名称:TravelApp,代码行数:32,代码来源:api-test.py
示例5: min_query
def min_query(self, term, limit=5, category='', radius=None, location='washington, dc', sort=0, offset=0):
'''A minimal query that returns a simple dictionary with the following key values.
The values returned include name, phone, display phone, location, categories, yelp rating, yelp review count, a rating image url, yelp url, and yelp mobile url
To simplify/minimize location, we return the neighborhood if available, else we return the city.'''
# create YelpAPI object
yelp_query = YelpAPI(self.consumer_key, self.consumer_secret, self.token, self.token_secret)
response = yelp_query.search_query(term=term, category_filter=category, limit=limit, radius_filter=radius, location=location, sort=sort, offset=offset)
print response
min_response = []
for entry in response['businesses']:
if 'neighborhoods' in entry['location'].keys():
location = entry['location']['neighborhoods'][0]
elif 'city' in entry['location']:
location = entry['location']['city']
else:
location = 'No neighborhood or city listed :('
categories = ''
if 'categories' in entry.keys():
for value in entry['categories'][:-1]:
categories = categories + value[0] + ', '
categories = categories + entry['categories'][-1][0]
key_list = ['name', 'phone', 'display_phone', 'rating', 'review_count', 'rating_img_url', 'url', 'mobile_url']
for key in key_list:
if key not in entry.keys():
entry[key] = 'None'
tmp_dict = {'name':entry['name'], 'phone':entry['phone'], 'display_phone':entry['display_phone'], 'location':location, 'categories':categories, 'rating':entry['rating'], 'review_count':entry['review_count'], 'rating_img_url':entry['rating_img_url'], 'url':entry['url'], 'mobile_url':entry['mobile_url']}
min_response.append(tmp_dict)
return min_response
开发者ID:CooperativeOrganizationOfPeople,项目名称:Brunch,代码行数:29,代码来源:yelp_api.py
示例6: food
def food(jenni, input):
if not hasattr(jenni.config, 'yelp_api_credentials'):
return
yelp_api = YelpAPI(jenni.config.yelp_api_credentials['consumer_key'], jenni.config.yelp_api_credentials['consumer_secret'], jenni.config.yelp_api_credentials['token'], jenni.config.yelp_api_credentials['token_secret'])
location = input.group(2)
if not location:
jenni.say("Please enter a location.")
return
done = False
max_offset = 5
try:
while not done:
offset = random.randint(0, max_offset)
response = yelp_api.search_query(category_filter="restaurants", location=location, limit=20, offset=offset)
if len(response['businesses']) > 0:
done = True
jenni.say("How about, " + response['businesses'][random.randint(0, len(response['businesses']) - 1)]['name'] + "?")
else:
max_offset = offset - 1
except YelpAPI.YelpAPIError:
jenni.say("Invalid location!")
开发者ID:Jarada,项目名称:jenni,代码行数:25,代码来源:food.py
示例7: full_query
def full_query(self, term, limit=5, category='', radius=None, location='washington, dc', sort=0):
'''A full query that passes back the full JSON response from Yelp. For more information on
seacch and response values see http://www.yelp.com/developers/documentation/v2/search_api'''
# create YelpAPI object
yelp_query = YelpAPI(self.consumer_key, self.consumer_secret, self.token, self.token_secret)
category=''
limit=5
radius=None
offset = 0
response = yelp_query.search_query(term=term, category_filter=category, limit=limit, radius_filter=radius, location=location, sort=sort, offset=offset)
return response
开发者ID:CooperativeOrganizationOfPeople,项目名称:Brunch,代码行数:12,代码来源:yelp_api.py
示例8: test_uses_timeout
def test_uses_timeout(self, has_timeout, faker, mock_request, random_dict):
url = faker.uri()
mock_call = mock_request.get(url, json=random_dict)
timeout_s = faker.random_int(1, 60) if has_timeout else None
yelp = YelpAPI(faker.pystr(), timeout_s=timeout_s)
assert 0 == mock_call.call_count
resp = yelp._query(url)
assert resp == random_dict
assert 1 == mock_call.call_count
assert timeout_s == mock_call.last_request.timeout
开发者ID:gfairchild,项目名称:yelpapi,代码行数:13,代码来源:test_yelpapi.py
示例9: __init__
def __init__(self):
self.BASE_URL = 'https://www.yelp.com/'
# auth = Oauth1Authenticator(consumer_key=YOUR_CONSUMER_KEY,consumer_secret=YOUR_CONSUMER_SECRET,token=YOUR_TOKEN,token_secret=YOUR_TOKEN_SECRET)
# auth = Oauth1Authenticator(consumer_key='pvImIXD6_9XDcw5TEBWdEw',consumer_secret='fBbKhobgly9fsjqnlsTNA5SyQI4',token='Nj9xR2XNdp0yQzf6eJysd9AJkj-FFW4M',token_secret='u5YhqlY6ptEoleexrhQZmqM5vg8')
# client = Client(auth)
self.yelp = YelpAPI('pvImIXD6_9XDcw5TEBWdEw','fBbKhobgly9fsjqnlsTNA5SyQI4','Nj9xR2XNdp0yQzf6eJysd9AJkj-FFW4M','u5YhqlY6ptEoleexrhQZmqM5vg8')
开发者ID:ab-geek,项目名称:DjangoWebScraper,代码行数:7,代码来源:yelp.py
示例10: Yelp
class Yelp():
def __init__(self):
self.BASE_URL = 'https://www.yelp.com/'
# auth = Oauth1Authenticator(consumer_key=YOUR_CONSUMER_KEY,consumer_secret=YOUR_CONSUMER_SECRET,token=YOUR_TOKEN,token_secret=YOUR_TOKEN_SECRET)
# auth = Oauth1Authenticator(consumer_key='pvImIXD6_9XDcw5TEBWdEw',consumer_secret='fBbKhobgly9fsjqnlsTNA5SyQI4',token='Nj9xR2XNdp0yQzf6eJysd9AJkj-FFW4M',token_secret='u5YhqlY6ptEoleexrhQZmqM5vg8')
# client = Client(auth)
self.yelp = YelpAPI('pvImIXD6_9XDcw5TEBWdEw','fBbKhobgly9fsjqnlsTNA5SyQI4','Nj9xR2XNdp0yQzf6eJysd9AJkj-FFW4M','u5YhqlY6ptEoleexrhQZmqM5vg8')
def getWebsite(self,url):
response = requests.get(url)
soup = BeautifulSoup(response.text)
try:
web = soup.find('div',{'class':'biz-website'}).find('a').text
return web
except:
return url
def search(self,params):
#response = client.search('San Francisco', **params)
#print response.businesses
response = self.yelp.search_query(term=params['term'],location=params['location'],limit=1)
print self.getWebsite(response['businesses'][0]['url'])
开发者ID:ab-geek,项目名称:DjangoWebScraper,代码行数:26,代码来源:yelp.py
示例11: callYelp
def callYelp(location,term,limit):
yelp_api = YelpAPI(CONSUMER_KEY, CONSUMER_SECRET, TOKEN, TOKEN_SECRET)
response = yelp_api.search_query(term=term, location=location, sort=0, limit=limit)
context_list = []
for r in response['businesses']:
single = {}
single['term'] = term
single['name'] = r['name']
single['address'] =r['location']['display_address']
single['link'] = r['url']
single['lat'] = r['location']['coordinate']['latitude']
single['lon'] = r['location']['coordinate']['longitude']
if r['is_closed'] == "False":
single['close'] = "CLOSE"
else:
single['close'] = "OPEN"
context_list.append(single)
return context_list
开发者ID:bxiao0801,项目名称:backup,代码行数:19,代码来源:apiCall.py
示例12: Yelp
class Yelp(object):
def __init__(self, longitude, latitude):
self.client = YelpAPI(CONSUMER_KEY, CONSUMER_SECRET, TOKEN, TOKEN_SECRET)
self.longitude = str(longitude)
self.latitude = str(latitude)
print(self.latitude, self.longitude)
def get_locations(self):
return self.client.search_query(
ll=self.latitude + ',' + self.longitude,
limit=5)
开发者ID:newtonjain,项目名称:hacktheplanet,代码行数:12,代码来源:yelp.py
示例13: YelpGain
def YelpGain(self):
from yelpapi import YelpAPI
MY_CONSUMER_KEY = 'dae5HXBIXTb0ChnDZkzB3w'
MY_CONSUMER_SECRET = 'qanTfPX5tMyh2hUFOMv-GgHgEUQ'
MY_ACCESS_TOKEN = '60i6KZ_lUoOMuqZKb1yUsQ4EuRZweqS5'
MY_ACCESS_SECRET = '0__YQm18_g2jUsMcbu6THu3edpA'
yelp_api = YelpAPI(consumer_key=MY_CONSUMER_KEY,
consumer_secret=MY_CONSUMER_SECRET,
token=MY_ACCESS_TOKEN,
token_secret=MY_ACCESS_SECRET)
yelpResult = {}
index = 1
response = yelp_api.search_query(term=info['yelp'], location='college station, tx', sort=2, limit=5)
for business in response['businesses']:
result = {}
result['name'] = str(business['name'])
result['id'] = str(business['id'])
result['rating'] = str(business['rating'])+ "(" + str(business['review_count'])+'reviews' + ")"
result['address'] = ', '.join(business['location']['display_address'])
yelpResult[index] = result
index = index + 1
return yelpResult
开发者ID:toming90,项目名称:2014Spring-CSCE670-Final-Project-Cupid,代码行数:24,代码来源:UI.py
示例14: YelpAPI
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 search by bounding box and category. See
# http://www.yelp.com/developers/documentation/v2/all_category_list
# for an official list of Yelp categories. The bounding box definition
# comes from
# http://isithackday.com/geoplanet-explorer/index.php?woeid=12587707.
print('***** 5 bike rentals in San Francisco county *****')
response = yelp_api.search_query(category_filter='bikerentals', bounds='37.678799,-123.125740|37.832371,-122.356979', limit=5)
for business in response['businesses']:
print('{}\n\tYelp ID: {}\n\trating: {} ({} reviews)\n\taddress: {}'.format(business['name'], business['id'], business['rating'],
business['review_count'], business['location']['display_address']))
开发者ID:makoshark,项目名称:yelp-api-cdsw,代码行数:18,代码来源:yelp2.py
示例15: YelpAPI
from yelpapi import YelpAPI
import pandas as pd
consumer_key = 'PnHvincoddn76xfpm3LhLg'
consumer_secret = 'PGmBEyjY0dKu1jzYkJr2Mxe2SCs'
token = 'Xo8UWIL1CdyTxn-cX-XYbxsAXQOpgfYz'
token_secret = '1J60nMB-wGTsLyNOyGkY9EZfMFM'
yelp_api = YelpAPI(consumer_key,consumer_secret,token,token_secret)
#search_results = yelp_api.search_query()
columns = ['bars','restaurants','laundry','pizza','hospitals','coffee','boutique','clothing','education','arts']
#zip_code = ['10453','10458','10451','10454','10463','10466','10461','11212','11209','11204','11234','11223','11201','11203','11207','11211','11220','11206','10026','10001','10029','10010','10012','10004','10002','10021','10023','10031','11361','11354','11365','11412','11101','11374','11691','11004','11414','11368','10301','10314']
zip_code = [10001, 10002, 10003, 10004, 10005, 10006, 10007, 10009, 10010, 10011, 10012, 10013, 10014, 10016, 10017, 10018, 10019, 10020, 10021, 10022, 10023, 10024, 10025, 10026, 10027, 10028, 10029, 10030, 10031, 10032, 10033, 10034, 10035, 10036, 10037, 10038, 10039, 10040, 10044, 10065, 10069, 10075, 10103, 10110, 10111, 10112, 10115, 10119, 10128, 10152, 10153, 10154, 10162, 10165, 10167, 10168, 10169, 10170, 10171, 10172, 10173, 10174, 10177, 10199, 10271, 10278, 10279, 10280, 10282, 10301, 10302, 10303, 10304, 10305, 10306, 10307, 10308, 10309, 10310, 10311, 10312, 10314, 10451, 10452, 10453, 10454, 10455, 10456, 10457, 10458, 10459, 10460, 10461, 10462, 10463, 10464, 10465, 10466, 10467, 10468, 10469, 10470, 10471, 10472, 10473, 10474, 10475, 11004, 11005, 11101, 11102, 11103, 11104, 11105, 11106, 11109, 11201, 11203, 11204, 11205, 11206, 11207, 11208, 11209, 11210, 11211, 11212, 11213, 11214, 11215, 11216, 11217, 11218, 11219, 11220, 11221, 11222, 11223, 11224, 11225, 11226, 11228, 11229, 11230, 11231, 11232, 11233, 11234, 11235, 11236, 11237, 11238, 11239, 11351, 11354, 11355, 11356, 11357, 11358, 11359, 11360, 11361, 11362, 11363, 11364, 11365, 11366, 11367, 11368, 11369, 11370, 11371, 11372, 11373, 11374, 11375, 11377, 11378, 11379, 11385, 11411, 11412, 11413, 11414, 11415, 11416, 11417, 11418, 11419, 11420, 11421, 11422, 11423, 11424, 11425, 11426, 11427, 11428, 11429, 11430, 11432, 11433, 11434, 11435, 11436, 11451, 11691, 11692, 11693, 11694, 11697]
d = {}
for i in columns:
count = d.setdefault(i, {})
for j in zip_code:
count = d[i].setdefault(j, 0)
business_results = yelp_api.search_query(term = i,location = j, radius_filter = 1000)
rating = 0
num = 0
for k in business_results['businesses']:
try:
if k['review_count']>500:
rating += (k['rating']/float(5))*3 + 2
else:
rating += (k['rating']/float(5))*3 + (k['review_count']/float(500))*2
#print k['name'],k['rating'],k['review_count'],k['location']['postal_code'],k['location']['neighborhoods']
except:
continue
rating = rating/float(20)
print i,j
开发者ID:julms,项目名称:Recommender-System,代码行数:31,代码来源:y1.py
示例16: documentation
# Answer to Challenge 1: Change your search in some way described in the API
# documentation (e.g., use a category filter)
#
# I've changed this to print ice cream places in Seattle using the category
# filter. I used the term "icecream" which I found documented on this page in
# the API documentation:
#
# https://www.yelp.com/developers/documentation/v2/all_category_list
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 search by location text and term. Take a look at
# http://www.yelp.com/developers/documentation/v2/search_api for
# the various options available.
print('***** 5 best rated ice cream places in Seattle, WA *****')
response = yelp_api.search_query(category_filter='icecream', location='seattle, wa', sort=2, limit=5)
print('region center (lat,long): {},{}\n'.format(response['region']['center']['latitude'], response['region']['center']['longitude']))
for business in response['businesses']:
print('{}\n\tYelp ID: {}\n\trating: {} ({} reviews)\n\taddress: {}'.format(business['name'], business['id'], business['rating'], business['review_count'], business['location']['display_address']))
开发者ID:makoshark,项目名称:yelp-api-cdsw-solutions,代码行数:26,代码来源:challenge_2.py
示例17: YelpAPI
# Answer to Challenge 6: What is the highest rated falafel place in Seattle?
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 search by location text and term. Take a look at
# http://www.yelp.com/developers/documentation/v2/search_api for
# the various options available.
response = yelp_api.search_query(term='falafel', location='seattle, wa', sort=2, limit=1)
for business in response['businesses']:
print('{}\n\trating: {} ({} reviews)'.format(business['name'], business['rating'], business['review_count']))
开发者ID:makoshark,项目名称:yelp-api-cdsw-solutions,代码行数:15,代码来源:challenge_6.py
示例18: range
from yelpapi import YelpAPI
yelp_api =YelpAPI('a5oBT4RnnHpt6rtHQWsGYg','61UpHpxNDVJfpACumIIJNIR2nJ8','-PlfjeTyjnMSGP67pQbopdxJ-lXE70Bn','ewGlo-jkCt0LpNYphzr2SxaEtCY')
neighborhoods = ['Alexandra', 'Ang Mo Kio', 'Ann Siang Hill', 'Arab Street', 'Bayfront', 'Bedok North', 'Bedok Reservoir', 'Bedok South', 'Bencoolen', 'Bishan', 'Boat Quay', 'Boon Keng', 'Boon Lay','Bras Brasah','Buangkok','Bugis','Bukit Batok','Bukit Panjang','Bukit Timah','Changi','Chinatown','Choa Chu Kang','City Hall','Clarke Quay','Clementi','Dempsey Hill','Dhoby Ghaut','Dover','Duxton Hill','Eunos','Farrer Park','Geylang','Ghim Moh','Harbourfront','Holland Hill','Holland Village','Hougang','Joo Chiat','Jurong','Jurong Island','Kallang','Katong','Kembangan','Kent Ridge','Keppel','Labrador Park','Lavender','Lim Chu Kang','Little India','Macpherson','Mandai','Marine Parade','Mount Sophia','Mountbatten','Newton','Novena','Orchard','Outram','Pasir Panjang','Pasir Ris','Paya Lebar','Potong Pasir','Pulau Ubin','Punggol','Queenstown','Raffles Place','Redhill','River Valley','Robertson Quay','Seletar','Sembawang','Sengkang','Sentosa','SerangoonSerangoon Gardens','Siglap','Simei','Sixth Avenue','Somerset','Tampines','Tanglin','Tanglin Halt','Tanjong Pagar','Tanjong Rhu','Telok Blangah','Telok Kurau','Thomson','Tiong Bahru','Toa Payoh','Tuas','Ubi','Ulu Pandan','Upper Bukit Timah','Wessex Estate','West Coast','Woodlands','Yio Chu Kang','Yishun','one-north']
resultsDict = []
for location in neighborhoods:
search_results = yelp_api.search_query(location=location, category_filter='food')
totalResults = search_results['total']
for x in range (0, min(50, totalResults/20)):
offsetValue = (str)(x*20)
print "Query", x
results = yelp_api.search_query(location=location, category_filter='food', offset=offsetValue)
resultsDict.append(results)
开发者ID:spinningarrow,项目名称:yelpy,代码行数:13,代码来源:yelpSearch2.py
示例19: YelpAPI
# Scrapes a whole city from Yelp.
import argparse, csv, collections, geojson, ConfigParser, time
from yelpapi import YelpAPI
from shapely import geometry
import util
parser = argparse.ArgumentParser()
parser.add_argument('--neighborhoods_file', default='data/sffind_neighborhoods.json')
parser.add_argument('--config_file', default='config.txt')
parser.add_argument('--output_file', default='yelp_results.json')
args = parser.parse_args()
config = ConfigParser.ConfigParser()
config.read('config.txt')
yelp_api = YelpAPI(config.get('yelp', 'consumer_key'),
config.get('yelp', 'consumer_secret'), config.get('yelp', 'token'),
config.get('yelp', 'token_secret'))
# results = yelp_api.search_query(term='coffee', location='Noe Valley, San Francisco, CA')
# https://www.yelp.com/developers/documentation/v2/search_api
num_results_so_far = 0
while True:
results = yelp_api.search_query(category_filter='coffee',
location='San Francisco, CA', offset=num_results_so_far)
print results['total']
for business in results['businesses']:
if business['is_closed']:
print "Not including, permanently closed: %s" % business['name']
continue
print business['name']
print business['location']['coordinate']
开发者ID:dantasse,项目名称:nghd_scraper,代码行数:31,代码来源:yelp.py
示例20: YelpAPI
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 search by location text and term. Take a look at
# http://www.yelp.com/developers/documentation/v2/search_api for
# the various options available.
print('***** 5 best rated ice cream places in Austin, TX *****')
response = yelp_api.search_query(term='ice cream', location='austin, tx', sort=2, limit=5)
print('region center (lat,long): {},{}\n'.format(response['region']['center']['latitude'], response['region']['center']['longitude']))
for business in response['businesses']:
print('{}\n\tYelp ID: {}\n\trating: {} ({} reviews)\n\taddress: {}'.format(business['name'], business['id'], business['rating'], business['review_count'], business['location']['display_address']))
开发者ID:makoshark,项目名称:yelp-api-cdsw,代码行数:17,代码来源:yelp1.py
注:本文中的yelpapi.YelpAPI类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论