本文整理汇总了Python中yelp.client.Client.search_by_bounding_box方法的典型用法代码示例。如果您正苦于以下问题:Python Client.search_by_bounding_box方法的具体用法?Python Client.search_by_bounding_box怎么用?Python Client.search_by_bounding_box使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yelp.client.Client
的用法示例。
在下文中一共展示了Client.search_by_bounding_box方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getresponse
# 需要导入模块: from yelp.client import Client [as 别名]
# 或者: from yelp.client.Client import search_by_bounding_box [as 别名]
def getresponse(term,lat,lon):
#term, location coords
R = 6371
radius = 2
filename = 'config_secret.json'
with io.open('/Users/thiyagesh/Desktop/yelp/drf-demo/drf_demo/model_less/config_secret.json') as cred:
creds = json.load(cred)
auth = Oauth1Authenticator(**creds)
client = Client(auth)
params = {
'term': term,
'lang': 'fr'
}
result = []
lat = float(lat)
lon = float(lon)
x1 = lon - math.degrees((radius*math.cos(math.radians(lat)))/R)
x2 = lon + math.degrees((radius*math.cos(math.radians(lat)))/R)
y1 = lat + math.degrees(radius/R)
y2 = lat - math.degrees(radius/R)
print "Original:",lat,lon
print "Next:",lat-0.001,lon+0.001
response = client.search_by_bounding_box(
lat+0.01,
lon-0.01,
lat-0.01,
lon+0.01,
**params
)
#response = client.search_by_coordinates(lat, long, **params)
for i in response.businesses:
result.append(i.name)
if len(result) != 0:
return result
else:
return None