Yelp Tests


In [4]:
def yelp_search(search_term):   
    """
    signs a yelp search request using the oauth2 library.
    """
    
    import oauth2
    import base64
    import passwords
    
    #get passwords
    my_info = passwords.get_secure_info()
    #'decrypt passwords'
    consumer_key = base64.b64decode(my_info['Consumer_Key'])
    consumer_secret = base64.b64decode(my_info['Consumer_Secret'])
    token = base64.b64decode(my_info['Token'])
    token_secret = base64.b64decode(my_info['Token_Secret'])
    
    
    #set querry vars
    reonomy_loc = '40.749281,-73.994369' # lat long coordinates
    distance = '400'                     # 5 blocks in meters
    
    #set querry
    url = ('http://api.yelp.com/v2/search?' \
            'sort=2&' \
            'term=%s&' \
            'll=%s&' \
            'radius_filter=%s'\
             %
            (search_term, reonomy_loc, distance))
    
    # use oauth2 to sign request and make querry
    consumer = oauth2.Consumer(consumer_key, consumer_secret)
    oauth_request = oauth2.Request('GET', url, {})
    oauth_request.update({'oauth_nonce': oauth2.generate_nonce(),
                          'oauth_timestamp': oauth2.generate_timestamp(),
                          'oauth_token': token,
                          'oauth_consumer_key': consumer_key})
    
    token = oauth2.Token(token, token_secret)
    
    oauth_request.sign_request(oauth2.SignatureMethod_HMAC_SHA1(), consumer, token)
    
    signed_url = oauth_request.to_url()
    
    return signed_url

In [5]:
def yelp_business(bid):   
    """
    signs a yelp search request using the oauth2 library.
    """
    
    import oauth2
    import base64
    import passwords
    
    #get passwords
    my_info = passwords.get_secure_info()
    #'decrypt passwords'
    consumer_key = base64.b64decode(my_info['Consumer_Key'])
    consumer_secret = base64.b64decode(my_info['Consumer_Secret'])
    token = base64.b64decode(my_info['Token'])
    token_secret = base64.b64decode(my_info['Token_Secret'])
    
    #set querry
    url = ('http://api.yelp.com/v2/business/%s' % bid)
    
    # use oauth2 to sign request and make querry
    consumer = oauth2.Consumer(consumer_key, consumer_secret)
    oauth_request = oauth2.Request('GET', url, {})
    oauth_request.update({'oauth_nonce': oauth2.generate_nonce(),
                          'oauth_timestamp': oauth2.generate_timestamp(),
                          'oauth_token': token,
                          'oauth_consumer_key': consumer_key})
    
    token = oauth2.Token(token, token_secret)
    
    oauth_request.sign_request(oauth2.SignatureMethod_HMAC_SHA1(), consumer, token)
    
    signed_url = oauth_request.to_url()
    
    return signed_url

In [6]:
def dist_convert(dist_meters):
    '''
    takes a distance in meteres and returns a distance in NYC Blocks
    '''
    feet_conversion = 3.28
    block_conversion = 264
    return ((dist_meters * feet_conversion) / block_conversion)

In [7]:
def connection(url):
    '''
    connects to yelp to extract data
    '''
    import urllib
    import urllib2
    import json
    
    try:
        conn = urllib2.urlopen(url, None)
        try:
            data = json.loads(conn.read())
        finally:
            conn.close()
    except urllib2.HTTPError, error:
        data = json.loads(error.read())
    
    return data

In [8]:
def find_lunch(search_term):
    '''
    querries yelp to get a list of delicous resturants
    '''
    
    #get search data from data from yelp
    data = connection(yelp_search(search_term))
    
    #explore data
    for b in data['businesses']:
        print ('Name=[%s], Phone # [%s], dist=[%2f], Rating [%s] stars from %s reviews' \
               %(b['name'], b['display_phone'], dist_convert(b['distance']), b['rating'], b['review_count']))
        print b['snippet_text'],  b['snippet_image_url']
        return b
        break

In [9]:
soup = find_lunch('soup')


Name=[HIT Korean Food & Deli], Phone # [+1-212-633-1530], dist=[3.844512], Rating [4.0] stars from 90 reviews
YES. WHAT. YES.

This is an actual hole in the wall in the deep pits of some building where one man surrounded by TVs, truck stop coffee machines and a... http://s3-media3.ak.yelpcdn.com/photo/VRyW83zLbo54rgC5A7oRRw/ms.jpg

In [52]:
t = 123.453463

In [55]:
d = str(t)[:5]
d


Out[55]:
'123.4'

In [10]:
import IPython.display as dsp

In [11]:
dsp.Image(url=soup['rating_img_url_large'])


Out[11]:

In [12]:
dsp.Image(url=soup['image_url'])


Out[12]:

In [13]:
soup['id']


Out[13]:
u'hit-korean-food-and-deli-new-york'

In [14]:
def business_profile(bid):
    profile = connection(yelp_business(bid))
    for r in profile['reviews']:
        print "Rating=[%s] Review: %s" % (r['rating'], r['excerpt'])

In [15]:
business_profile(soup['id'])


Rating=[4] Review: There's not much I can say about this place that hasn't already been said - it's cheap, delicious, no-frills Korean food.  It's definitely a hole in the...
Rating=[5] Review: YES. WHAT. YES.

This is an actual hole in the wall in the deep pits of some building where one man surrounded by TVs, truck stop coffee machines and a...
Rating=[3] Review: Jeyuk Bokkeum ($8.95) - fresly made stir-fried pork didn't excite me but acceptable. The cabbage salad with mayo refreshed the spicy and heavy taste of...

In [16]:
def find_lunch(search_term):
    '''
    querries yelp to get a list of delicous resturants
    '''
    
    #get search data from data from yelp
    data = connection(yelp_search(search_term))
    
    #explore data
    for b in data['businesses']:
        print ('Name=[%s], Phone # [%s], dist=[%.2f blocks], Rating [%s] stars from %s reviews' \
               %(b['name'], b['display_phone'], dist_convert(b['distance']), b['rating'], b['review_count']))
        #get business ratings
        business_profile(b['id'])
        print '\n[----Next Business-----------------] \n'

In [17]:
find_lunch('soup')


Name=[HIT Korean Food & Deli], Phone # [+1-212-633-1530], dist=[3.84 blocks], Rating [4.0] stars from 90 reviews
Rating=[4] Review: There's not much I can say about this place that hasn't already been said - it's cheap, delicious, no-frills Korean food.  It's definitely a hole in the...
Rating=[5] Review: YES. WHAT. YES.

This is an actual hole in the wall in the deep pits of some building where one man surrounded by TVs, truck stop coffee machines and a...
Rating=[3] Review: Jeyuk Bokkeum ($8.95) - fresly made stir-fried pork didn't excite me but acceptable. The cabbage salad with mayo refreshed the spicy and heavy taste of...

[----Next Business-----------------] 

Name=[Soup Spot], Phone # [+1-212-643-8623], dist=[1.77 blocks], Rating [4.5] stars from 120 reviews
Rating=[4] Review: This is my new favorite place to go during lunchtime! It's a perfect spot to grab a delicious lunch and take it back to the office or find a place outside...
Rating=[5] Review: My new favorite place to have lunch! It's a super tiny hole in the wall joint that has rotating soup options. With each soup (even the small ones), you get...
Rating=[3] Review: Like Chipotle near 34th and 8th, this place always has a line during lunch but moves pretty quickly. 

Soup Spot has a vast array of soups but only 18...

[----Next Business-----------------] 

Name=[Pio Pio Riko], Phone # [+1-212-643-7555], dist=[1.38 blocks], Rating [4.0] stars from 38 reviews
Rating=[4] Review: My friend and I had lunch here before catching a movie. I found this place on yelp and was so happy that I did! Honestly, I think I may have had Peruvian...
Rating=[3] Review: Derricious! 

Restaurant is very clean and the waitstaff is extremely friendly.

The half-chicken combo is such a steal! For $10, you get a LOT of food -...
Rating=[5] Review: I have an obsession with Peruvian chicken and this fast food like joint delivers like no other... perfect for a quick, cheap and delicious lunch option in...

[----Next Business-----------------] 

Name=[Brooklyn Bagel & Coffee Company], Phone # [+1-212-924-2824], dist=[5.45 blocks], Rating [4.0] stars from 309 reviews
Rating=[5] Review: I love coming here. I live just across the street. 

Usually, they really love putting a lot of cream cheese on the bagels. But I always ask for them to not...
Rating=[5] Review: MIND BLOWN. Renewed my faith in bagels.

Tofu 'cream cheese' was phenomenal. I am still having dreams of this place....
Rating=[3] Review: I really wanted to like this place. And in some ways, I did:

Their food is great and their bagels are really big and tasty. Don't get fooled by the label...

[----Next Business-----------------] 

Name=[Penn Sushi], Phone # [+1-212-564-5496], dist=[2.70 blocks], Rating [4.0] stars from 18 reviews
Rating=[4] Review: Went to this place to get something before my train to DC.  Loved the food and selection of Japanese fast food.  Left very happy; but unfortunately, my soup...
Rating=[4] Review: I usually end up getting to Penn Station early for an Amtrak, and have frequented Penn Sushi many times. Always fresh and it's a nice healthy alternative to...
Rating=[4] Review: This place is a little gem. It is a very small stand but they have amazing products and even better service. 

There sushi is the best in midtown with...

[----Next Business-----------------] 

Name=[Mooncake Foods], Phone # [+1-212-268-2888], dist=[0.55 blocks], Rating [3.5] stars from 243 reviews
Rating=[4] Review: I love coming to mooncake foods for lunch. I've brought different co-workers on different occasions and they enjoyed it as well. 

I like:
-Grilled Squid w/...
Rating=[4] Review: I actually enjoyed the food and the loudness that comes with! I've only been at this establishment once and I'm hooked!  Look, I'm not saying this is...
Rating=[4] Review: Conveniently close to both Madison Square Garden and New York Penn Station, Mooncakes is my go-to eats spot before a MSG event or when meeting up with...

[----Next Business-----------------] 

Name=[Caribbean Kitchen], Phone # [+1-212-290-2864], dist=[3.07 blocks], Rating [3.5] stars from 31 reviews
Rating=[5] Review: This place is great for lunch. I'm not Caribbean but this food is very delicious to me: Jerk Chicken, Caribbean Curry Chicken, Jerk Pork, Curry Goat,...
Rating=[1] Review: My review is not fair because I didn't even eat there. By the time I walked down the sketchiest hidden block in midtown, I was first greeted by a urine and...
Rating=[4] Review: Used to work nearby and this place was like having Brooklyn in the middle of midtown except they definitely don't have Brooklyn prices.  I'm a fan of the...

[----Next Business-----------------] 

Name=[Loving Hut], Phone # [+1-212-760-1900], dist=[2.36 blocks], Rating [3.5] stars from 175 reviews
Rating=[3] Review: It's consistently really good but not stellar. You probably won't feel the urge to lick your plate. If you're vegan you're in luck and know you'll be...
Rating=[2] Review: Recently I've had to make some diet changes and was excited to find a vegan restaurant near to my job. Getting lunch at a vegan place makes it so much...
Rating=[2] Review: I find that Loving Huts are a hit or miss experience, both in terms of the restaurant itself and in terms of what you end up choosing off the menu. 

I ran...

[----Next Business-----------------] 

Name=[Kobeyaki], Phone # [+1-212-242-5500], dist=[4.01 blocks], Rating [3.5] stars from 123 reviews
Rating=[4] Review: While waiting in line a couple in front of me said "This place is weird lets leave."  This sealed the deal for me, I got a shorter line and I love weird.  I...
Rating=[2] Review: Popped in here twice this week. Got the same thing- Grilled Vegetable roll without eel sauce. The roll itself is pretty delicious however the service is...
Rating=[3] Review: Not a bad place for lunch. The burger and sweet potato fries are a good choice.

I wouldn't recommend the ramen -- it's bland, lacks ingredients, too...

[----Next Business-----------------] 

Name=[Lz Sushi], Phone # [+1-212-868-1388], dist=[2.71 blocks], Rating [4.0] stars from 25 reviews
Rating=[4] Review: Lz Sushi is a tiny sushi place with great value. It is perfect to pick up for lunch or bring home for dinner. The sushi is inexpensive and tastes delicious....
Rating=[4] Review: Lz Sushi is my go-to takeout sushi lunch place. Its pretty much a hole in the wall, but they have a nice selection of pre-packaged sushi waiting whenever...
Rating=[3] Review: Again looking around NYC during my recent trip for a bite to eat, I consulted my Yelp phone app for some options. LZ Sushi came up and fairly near, so I...

[----Next Business-----------------] 

Name=[Bistro Market Place], Phone # [+1-212-239-7050], dist=[4.46 blocks], Rating [3.5] stars from 53 reviews
Rating=[2] Review: I was looking for a cafe for Sunday brunch near the Manhattan Center, and I found this bistro to be unimpressive. 

First of all, their coffee products were...
Rating=[4] Review: Big selection of packaged foods, fresh fruits and salads, and cooked meals. 

Nice sitting area. 

They manage lines well. 

They should have more yogurts
Rating=[3] Review: Dropped in here yesterday to pick up some snacks before boarding the Rocks Off Party bus to Iron Maiden concert at Jones Beach. Nice bistro deli with a ton...

[----Next Business-----------------] 

Name=[Lily Farm Corp], Phone # [+1-212-243-4673], dist=[4.17 blocks], Rating [4.0] stars from 4 reviews
Rating=[4] Review: My coworkers  swear by the sandwiches here, which I have never had but I did recently discover the Japanese food counter and have been on a yuzu udon noodle...
Rating=[4] Review: My coworker introduced me to this place  and they make the best sandwiches.  The service is very good and they never mess up my order.  I ordered roast beef...
Rating=[4] Review: They have got my attention with the large variety of lunch specials they offer & their super-low prices.  

They have a hot & cold buffet featuring...

[----Next Business-----------------] 

Name=[Express Chinese & Japanese], Phone # [+1-212-564-2079], dist=[1.80 blocks], Rating [3.5] stars from 5 reviews
Rating=[5] Review: BEST DUMPLINGS I'VE EVER HAD!!!!  I'll never go anywhere else. 

I've eaten at many hundreds of Chinese restaurants in my life.
The STEAMED VEGETABLE...
---------------------------------------------------------------------------
UnicodeEncodeError                        Traceback (most recent call last)
<ipython-input-17-d50401e313b5> in <module>()
----> 1 find_lunch('soup')

<ipython-input-16-664c2dd8d117> in find_lunch(search_term)
     11         print ('Name=[%s], Phone # [%s], dist=[%.2f blocks], Rating [%s] stars from %s reviews'                %(b['name'], b['display_phone'], dist_convert(b['distance']), b['rating'], b['review_count']))
     12         #get business ratings
---> 13         business_profile(b['id'])
     14         print '\n[----Next Business-----------------] \n'
     15 

<ipython-input-14-cc2d997921e5> in business_profile(bid)
      1 def business_profile(bid):
----> 2     profile = connection(yelp_business(bid))
      3     for r in profile['reviews']:
      4         print "Rating=[%s] Review: %s" % (r['rating'], r['excerpt'])

<ipython-input-7-31f87fe0c44c> in connection(url)
      8 
      9     try:
---> 10         conn = urllib2.urlopen(url, None)
     11         try:
     12             data = json.loads(conn.read())

/usr/lib/python2.7/urllib2.pyc in urlopen(url, data, timeout)
    125     if _opener is None:
    126         _opener = build_opener()
--> 127     return _opener.open(url, data, timeout)
    128 
    129 def install_opener(opener):

/usr/lib/python2.7/urllib2.pyc in open(self, fullurl, data, timeout)
    402             req = meth(req)
    403 
--> 404         response = self._open(req, data)
    405 
    406         # post-process response

/usr/lib/python2.7/urllib2.pyc in _open(self, req, data)
    420         protocol = req.get_type()
    421         result = self._call_chain(self.handle_open, protocol, protocol +
--> 422                                   '_open', req)
    423         if result:
    424             return result

/usr/lib/python2.7/urllib2.pyc in _call_chain(self, chain, kind, meth_name, *args)
    380             func = getattr(handler, meth_name)
    381 
--> 382             result = func(*args)
    383             if result is not None:
    384                 return result

/usr/lib/python2.7/urllib2.pyc in http_open(self, req)
   1212 
   1213     def http_open(self, req):
-> 1214         return self.do_open(httplib.HTTPConnection, req)
   1215 
   1216     http_request = AbstractHTTPHandler.do_request_

/usr/lib/python2.7/urllib2.pyc in do_open(self, http_class, req)
   1179 
   1180         try:
-> 1181             h.request(req.get_method(), req.get_selector(), req.data, headers)
   1182         except socket.error, err: # XXX what error?
   1183             h.close()

/usr/lib/python2.7/httplib.pyc in request(self, method, url, body, headers)
    971     def request(self, method, url, body=None, headers={}):
    972         """Send a complete request to the server."""
--> 973         self._send_request(method, url, body, headers)
    974 
    975     def _set_content_length(self, body):

/usr/lib/python2.7/httplib.pyc in _send_request(self, method, url, body, headers)
   1005         for hdr, value in headers.iteritems():
   1006             self.putheader(hdr, value)
-> 1007         self.endheaders(body)
   1008 
   1009     def getresponse(self, buffering=False):

/usr/lib/python2.7/httplib.pyc in endheaders(self, message_body)
    967         else:
    968             raise CannotSendHeader()
--> 969         self._send_output(message_body)
    970 
    971     def request(self, method, url, body=None, headers={}):

/usr/lib/python2.7/httplib.pyc in _send_output(self, message_body)
    827             msg += message_body
    828             message_body = None
--> 829         self.send(msg)
    830         if message_body is not None:
    831             #message_body was not a string (i.e. it is a file) and

/usr/lib/python2.7/httplib.pyc in send(self, data)
    803                 datablock = data.read(blocksize)
    804         else:
--> 805             self.sock.sendall(data)
    806 
    807     def _output(self, s):

/usr/lib/python2.7/socket.pyc in meth(name, self, *args)
    222 
    223 def meth(name,self,*args):
--> 224     return getattr(self._sock,name)(*args)
    225 
    226 for _m in _socketmethods:

UnicodeEncodeError: 'ascii' codec can't encode character u'\xf3' in position 25: ordinal not in range(128)
Rating=[4] Review: Overall, this place is the generic greasy Chinese food one hopes for. 

The General Tso's chicken is quite good. They offer brown rice as an alternative to...
Rating=[3] Review: Yup, it's generic Chinese food. I was in the mood for lunch one day at work and surprisingly this is one of the few around 7th and 32nd. There's a lot of...

[----Next Business-----------------] 

Name=[Tir na nÓg], Phone # [+1-212-630-0249], dist=[3.71 blocks], Rating [3.5] stars from 97 reviews

In [44]:
def business_profile(bid):
    '''
    gets information specific to the business
    '''
    return connection(yelp_business(bid))

In [45]:
def find_lunch(search_term):
    '''
    queries yelp to get a list of delicious restaurants
    '''
    queried_resturants = []
    #get search data from data from yelp
    data = connection(yelp_search(search_term))
    
    #extract data
    combiner = []
    for b in data['businesses']:
        #clear out combiner
        combiner[:] = []
        
        combiner.append(b) # append search results
        combiner.append(business_profile(b['id'])) # append business profile results
        
        queried_resturants.append(combiner) # package for later acess
        break # limit to 1 query for now

    return queried_resturants,b

In [46]:
business_profile(b['id'])


Out[46]:
{u'categories': [[u'Korean', u'korean'],
  [u'Delis', u'delis'],
  [u'Sandwiches', u'sandwiches']],
 u'display_phone': u'+1-212-633-1530',
 u'id': u'hit-korean-food-and-deli-new-york',
 u'image_url': u'http://s3-media4.ak.yelpcdn.com/bphoto/3jCAMsmVsnHkT601v_xmmA/ms.jpg',
 u'is_claimed': True,
 u'is_closed': False,
 u'location': {u'address': [u'150 W 28th St'],
  u'city': u'New York',
  u'country_code': u'US',
  u'cross_streets': u'7th Ave & Avenue Of The Americas',
  u'display_address': [u'150 W 28th St',
   u'(b/t 7th Ave & Avenue Of The Americas)',
   u'Chelsea',
   u'New York, NY 10001'],
  u'neighborhoods': [u'Chelsea'],
  u'postal_code': u'10001',
  u'state_code': u'NY'},
 u'mobile_url': u'http://m.yelp.com/biz/hit-korean-food-and-deli-new-york',
 u'name': u'HIT Korean Food & Deli',
 u'phone': u'2126331530',
 u'rating': 4.0,
 u'rating_img_url': u'http://s3-media4.ak.yelpcdn.com/assets/2/www/img/c2f3dd9799a5/ico/stars/v1/stars_4.png',
 u'rating_img_url_large': u'http://s3-media2.ak.yelpcdn.com/assets/2/www/img/ccf2b76faa2c/ico/stars/v1/stars_large_4.png',
 u'rating_img_url_small': u'http://s3-media4.ak.yelpcdn.com/assets/2/www/img/f62a5be2f902/ico/stars/v1/stars_small_4.png',
 u'review_count': 90,
 u'reviews': [{u'excerpt': u"There's not much I can say about this place that hasn't already been said - it's cheap, delicious, no-frills Korean food.  It's definitely a hole in the...",
   u'id': u'UVVWEkllmOZJeyiqhAUsdg',
   u'rating': 4,
   u'rating_image_large_url': u'http://s3-media2.ak.yelpcdn.com/assets/2/www/img/ccf2b76faa2c/ico/stars/v1/stars_large_4.png',
   u'rating_image_small_url': u'http://s3-media4.ak.yelpcdn.com/assets/2/www/img/f62a5be2f902/ico/stars/v1/stars_small_4.png',
   u'rating_image_url': u'http://s3-media4.ak.yelpcdn.com/assets/2/www/img/c2f3dd9799a5/ico/stars/v1/stars_4.png',
   u'time_created': 1372109340,
   u'user': {u'id': u'KSxhZC2jiRfqfnhyEvEPbg',
    u'image_url': u'http://s3-media2.ak.yelpcdn.com/photo/6JkrORXcHgQlBCA4Toyy8Q/ms.jpg',
    u'name': u'Lucy H.'}},
  {u'excerpt': u'YES. WHAT. YES.\n\nThis is an actual hole in the wall in the deep pits of some building where one man surrounded by TVs, truck stop coffee machines and a...',
   u'id': u'Qn4EKdjF4WnuEAUbQEn6WA',
   u'rating': 5,
   u'rating_image_large_url': u'http://s3-media3.ak.yelpcdn.com/assets/2/www/img/22affc4e6c38/ico/stars/v1/stars_large_5.png',
   u'rating_image_small_url': u'http://s3-media1.ak.yelpcdn.com/assets/2/www/img/c7623205d5cd/ico/stars/v1/stars_small_5.png',
   u'rating_image_url': u'http://s3-media1.ak.yelpcdn.com/assets/2/www/img/f1def11e4e79/ico/stars/v1/stars_5.png',
   u'time_created': 1368888143,
   u'user': {u'id': u'SQIfkwKkwH_iD-urr0Fiew',
    u'image_url': u'http://s3-media3.ak.yelpcdn.com/photo/VRyW83zLbo54rgC5A7oRRw/ms.jpg',
    u'name': u'Jenna I.'}},
  {u'excerpt': u"Jeyuk Bokkeum ($8.95) - fresly made stir-fried pork didn't excite me but acceptable. The cabbage salad with mayo refreshed the spicy and heavy taste of...",
   u'id': u'fmYh2seLdYTD44YCGeA_zA',
   u'rating': 3,
   u'rating_image_large_url': u'http://s3-media1.ak.yelpcdn.com/assets/2/www/img/e8b5b79d37ed/ico/stars/v1/stars_large_3.png',
   u'rating_image_small_url': u'http://s3-media3.ak.yelpcdn.com/assets/2/www/img/902abeed0983/ico/stars/v1/stars_small_3.png',
   u'rating_image_url': u'http://s3-media3.ak.yelpcdn.com/assets/2/www/img/34bc8086841c/ico/stars/v1/stars_3.png',
   u'time_created': 1368239899,
   u'user': {u'id': u'zVcR8aYFgbgxzGCdpja1Ow',
    u'image_url': u'http://s3-media3.ak.yelpcdn.com/photo/235sz3MhwgSj4STdg71zew/ms.jpg',
    u'name': u'Taiyo O.'}}],
 u'snippet_image_url': u'http://s3-media3.ak.yelpcdn.com/photo/VRyW83zLbo54rgC5A7oRRw/ms.jpg',
 u'snippet_text': u'YES. WHAT. YES.\n\nThis is an actual hole in the wall in the deep pits of some building where one man surrounded by TVs, truck stop coffee machines and a...',
 u'url': u'http://www.yelp.com/biz/hit-korean-food-and-deli-new-york'}

In [47]:
qr,b = find_lunch('soup')

In [48]:
for r in qr:
    print r


[{u'is_claimed': True, u'distance': 309.43635660339214, u'mobile_url': u'http://m.yelp.com/biz/hit-korean-food-and-deli-new-york', u'rating_img_url': u'http://s3-media4.ak.yelpcdn.com/assets/2/www/img/c2f3dd9799a5/ico/stars/v1/stars_4.png', u'review_count': 90, u'name': u'HIT Korean Food & Deli', u'rating': 4.0, u'url': u'http://www.yelp.com/biz/hit-korean-food-and-deli-new-york', u'categories': [[u'Korean', u'korean'], [u'Delis', u'delis'], [u'Sandwiches', u'sandwiches']], u'is_closed': False, u'phone': u'2126331530', u'snippet_text': u'YES. WHAT. YES.\n\nThis is an actual hole in the wall in the deep pits of some building where one man surrounded by TVs, truck stop coffee machines and a...', u'image_url': u'http://s3-media4.ak.yelpcdn.com/bphoto/3jCAMsmVsnHkT601v_xmmA/ms.jpg', u'location': {u'cross_streets': u'7th Ave & Avenue Of The Americas', u'city': u'New York', u'display_address': [u'150 W 28th St', u'(b/t 7th Ave & Avenue Of The Americas)', u'Chelsea', u'New York, NY 10001'], u'neighborhoods': [u'Chelsea'], u'postal_code': u'10001', u'country_code': u'US', u'address': [u'150 W 28th St'], u'state_code': u'NY'}, u'display_phone': u'+1-212-633-1530', u'rating_img_url_large': u'http://s3-media2.ak.yelpcdn.com/assets/2/www/img/ccf2b76faa2c/ico/stars/v1/stars_large_4.png', u'id': u'hit-korean-food-and-deli-new-york', u'snippet_image_url': u'http://s3-media3.ak.yelpcdn.com/photo/VRyW83zLbo54rgC5A7oRRw/ms.jpg', u'rating_img_url_small': u'http://s3-media4.ak.yelpcdn.com/assets/2/www/img/f62a5be2f902/ico/stars/v1/stars_small_4.png'}, {u'is_claimed': True, u'rating': 4.0, u'mobile_url': u'http://m.yelp.com/biz/hit-korean-food-and-deli-new-york', u'rating_img_url': u'http://s3-media4.ak.yelpcdn.com/assets/2/www/img/c2f3dd9799a5/ico/stars/v1/stars_4.png', u'review_count': 90, u'name': u'HIT Korean Food & Deli', u'rating_img_url_small': u'http://s3-media4.ak.yelpcdn.com/assets/2/www/img/f62a5be2f902/ico/stars/v1/stars_small_4.png', u'url': u'http://www.yelp.com/biz/hit-korean-food-and-deli-new-york', u'is_closed': False, u'reviews': [{u'rating': 4, u'excerpt': u"There's not much I can say about this place that hasn't already been said - it's cheap, delicious, no-frills Korean food.  It's definitely a hole in the...", u'time_created': 1372109340, u'rating_image_url': u'http://s3-media4.ak.yelpcdn.com/assets/2/www/img/c2f3dd9799a5/ico/stars/v1/stars_4.png', u'rating_image_small_url': u'http://s3-media4.ak.yelpcdn.com/assets/2/www/img/f62a5be2f902/ico/stars/v1/stars_small_4.png', u'user': {u'image_url': u'http://s3-media2.ak.yelpcdn.com/photo/6JkrORXcHgQlBCA4Toyy8Q/ms.jpg', u'id': u'KSxhZC2jiRfqfnhyEvEPbg', u'name': u'Lucy H.'}, u'rating_image_large_url': u'http://s3-media2.ak.yelpcdn.com/assets/2/www/img/ccf2b76faa2c/ico/stars/v1/stars_large_4.png', u'id': u'UVVWEkllmOZJeyiqhAUsdg'}, {u'rating': 5, u'excerpt': u'YES. WHAT. YES.\n\nThis is an actual hole in the wall in the deep pits of some building where one man surrounded by TVs, truck stop coffee machines and a...', u'time_created': 1368888143, u'rating_image_url': u'http://s3-media1.ak.yelpcdn.com/assets/2/www/img/f1def11e4e79/ico/stars/v1/stars_5.png', u'rating_image_small_url': u'http://s3-media1.ak.yelpcdn.com/assets/2/www/img/c7623205d5cd/ico/stars/v1/stars_small_5.png', u'user': {u'image_url': u'http://s3-media3.ak.yelpcdn.com/photo/VRyW83zLbo54rgC5A7oRRw/ms.jpg', u'id': u'SQIfkwKkwH_iD-urr0Fiew', u'name': u'Jenna I.'}, u'rating_image_large_url': u'http://s3-media3.ak.yelpcdn.com/assets/2/www/img/22affc4e6c38/ico/stars/v1/stars_large_5.png', u'id': u'Qn4EKdjF4WnuEAUbQEn6WA'}, {u'rating': 3, u'excerpt': u"Jeyuk Bokkeum ($8.95) - fresly made stir-fried pork didn't excite me but acceptable. The cabbage salad with mayo refreshed the spicy and heavy taste of...", u'time_created': 1368239899, u'rating_image_url': u'http://s3-media3.ak.yelpcdn.com/assets/2/www/img/34bc8086841c/ico/stars/v1/stars_3.png', u'rating_image_small_url': u'http://s3-media3.ak.yelpcdn.com/assets/2/www/img/902abeed0983/ico/stars/v1/stars_small_3.png', u'user': {u'image_url': u'http://s3-media3.ak.yelpcdn.com/photo/235sz3MhwgSj4STdg71zew/ms.jpg', u'id': u'zVcR8aYFgbgxzGCdpja1Ow', u'name': u'Taiyo O.'}, u'rating_image_large_url': u'http://s3-media1.ak.yelpcdn.com/assets/2/www/img/e8b5b79d37ed/ico/stars/v1/stars_large_3.png', u'id': u'fmYh2seLdYTD44YCGeA_zA'}], u'phone': u'2126331530', u'snippet_text': u'YES. WHAT. YES.\n\nThis is an actual hole in the wall in the deep pits of some building where one man surrounded by TVs, truck stop coffee machines and a...', u'image_url': u'http://s3-media4.ak.yelpcdn.com/bphoto/3jCAMsmVsnHkT601v_xmmA/ms.jpg', u'categories': [[u'Korean', u'korean'], [u'Delis', u'delis'], [u'Sandwiches', u'sandwiches']], u'display_phone': u'+1-212-633-1530', u'rating_img_url_large': u'http://s3-media2.ak.yelpcdn.com/assets/2/www/img/ccf2b76faa2c/ico/stars/v1/stars_large_4.png', u'id': u'hit-korean-food-and-deli-new-york', u'snippet_image_url': u'http://s3-media3.ak.yelpcdn.com/photo/VRyW83zLbo54rgC5A7oRRw/ms.jpg', u'location': {u'cross_streets': u'7th Ave & Avenue Of The Americas', u'city': u'New York', u'display_address': [u'150 W 28th St', u'(b/t 7th Ave & Avenue Of The Americas)', u'Chelsea', u'New York, NY 10001'], u'neighborhoods': [u'Chelsea'], u'postal_code': u'10001', u'country_code': u'US', u'address': [u'150 W 28th St'], u'state_code': u'NY'}}]

In [ ]:
r[0] # search

In [50]:
r[1] # business


Out[50]:
{u'categories': [[u'Korean', u'korean'],
  [u'Delis', u'delis'],
  [u'Sandwiches', u'sandwiches']],
 u'display_phone': u'+1-212-633-1530',
 u'id': u'hit-korean-food-and-deli-new-york',
 u'image_url': u'http://s3-media4.ak.yelpcdn.com/bphoto/3jCAMsmVsnHkT601v_xmmA/ms.jpg',
 u'is_claimed': True,
 u'is_closed': False,
 u'location': {u'address': [u'150 W 28th St'],
  u'city': u'New York',
  u'country_code': u'US',
  u'cross_streets': u'7th Ave & Avenue Of The Americas',
  u'display_address': [u'150 W 28th St',
   u'(b/t 7th Ave & Avenue Of The Americas)',
   u'Chelsea',
   u'New York, NY 10001'],
  u'neighborhoods': [u'Chelsea'],
  u'postal_code': u'10001',
  u'state_code': u'NY'},
 u'mobile_url': u'http://m.yelp.com/biz/hit-korean-food-and-deli-new-york',
 u'name': u'HIT Korean Food & Deli',
 u'phone': u'2126331530',
 u'rating': 4.0,
 u'rating_img_url': u'http://s3-media4.ak.yelpcdn.com/assets/2/www/img/c2f3dd9799a5/ico/stars/v1/stars_4.png',
 u'rating_img_url_large': u'http://s3-media2.ak.yelpcdn.com/assets/2/www/img/ccf2b76faa2c/ico/stars/v1/stars_large_4.png',
 u'rating_img_url_small': u'http://s3-media4.ak.yelpcdn.com/assets/2/www/img/f62a5be2f902/ico/stars/v1/stars_small_4.png',
 u'review_count': 90,
 u'reviews': [{u'excerpt': u"There's not much I can say about this place that hasn't already been said - it's cheap, delicious, no-frills Korean food.  It's definitely a hole in the...",
   u'id': u'UVVWEkllmOZJeyiqhAUsdg',
   u'rating': 4,
   u'rating_image_large_url': u'http://s3-media2.ak.yelpcdn.com/assets/2/www/img/ccf2b76faa2c/ico/stars/v1/stars_large_4.png',
   u'rating_image_small_url': u'http://s3-media4.ak.yelpcdn.com/assets/2/www/img/f62a5be2f902/ico/stars/v1/stars_small_4.png',
   u'rating_image_url': u'http://s3-media4.ak.yelpcdn.com/assets/2/www/img/c2f3dd9799a5/ico/stars/v1/stars_4.png',
   u'time_created': 1372109340,
   u'user': {u'id': u'KSxhZC2jiRfqfnhyEvEPbg',
    u'image_url': u'http://s3-media2.ak.yelpcdn.com/photo/6JkrORXcHgQlBCA4Toyy8Q/ms.jpg',
    u'name': u'Lucy H.'}},
  {u'excerpt': u'YES. WHAT. YES.\n\nThis is an actual hole in the wall in the deep pits of some building where one man surrounded by TVs, truck stop coffee machines and a...',
   u'id': u'Qn4EKdjF4WnuEAUbQEn6WA',
   u'rating': 5,
   u'rating_image_large_url': u'http://s3-media3.ak.yelpcdn.com/assets/2/www/img/22affc4e6c38/ico/stars/v1/stars_large_5.png',
   u'rating_image_small_url': u'http://s3-media1.ak.yelpcdn.com/assets/2/www/img/c7623205d5cd/ico/stars/v1/stars_small_5.png',
   u'rating_image_url': u'http://s3-media1.ak.yelpcdn.com/assets/2/www/img/f1def11e4e79/ico/stars/v1/stars_5.png',
   u'time_created': 1368888143,
   u'user': {u'id': u'SQIfkwKkwH_iD-urr0Fiew',
    u'image_url': u'http://s3-media3.ak.yelpcdn.com/photo/VRyW83zLbo54rgC5A7oRRw/ms.jpg',
    u'name': u'Jenna I.'}},
  {u'excerpt': u"Jeyuk Bokkeum ($8.95) - fresly made stir-fried pork didn't excite me but acceptable. The cabbage salad with mayo refreshed the spicy and heavy taste of...",
   u'id': u'fmYh2seLdYTD44YCGeA_zA',
   u'rating': 3,
   u'rating_image_large_url': u'http://s3-media1.ak.yelpcdn.com/assets/2/www/img/e8b5b79d37ed/ico/stars/v1/stars_large_3.png',
   u'rating_image_small_url': u'http://s3-media3.ak.yelpcdn.com/assets/2/www/img/902abeed0983/ico/stars/v1/stars_small_3.png',
   u'rating_image_url': u'http://s3-media3.ak.yelpcdn.com/assets/2/www/img/34bc8086841c/ico/stars/v1/stars_3.png',
   u'time_created': 1368239899,
   u'user': {u'id': u'zVcR8aYFgbgxzGCdpja1Ow',
    u'image_url': u'http://s3-media3.ak.yelpcdn.com/photo/235sz3MhwgSj4STdg71zew/ms.jpg',
    u'name': u'Taiyo O.'}}],
 u'snippet_image_url': u'http://s3-media3.ak.yelpcdn.com/photo/VRyW83zLbo54rgC5A7oRRw/ms.jpg',
 u'snippet_text': u'YES. WHAT. YES.\n\nThis is an actual hole in the wall in the deep pits of some building where one man surrounded by TVs, truck stop coffee machines and a...',
 u'url': u'http://www.yelp.com/biz/hit-korean-food-and-deli-new-york'}

In [ ]: