예제 #1
0
    def __import(self):
        client = Client(self.__auth)
        params = {
            'term': 'food',
            'limit': 20,
        }

        file = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                            "city_names.txt")

        with open(file) as f:
            lines = f.readlines()

        states = StateSeeder()
        submissionList = []

        for city in lines:
            print "Searching for " + city
            locationParam = city.strip() + ", USA"
            results = client.search(locationParam, **params)
            state = states.lookupState(
                results.businesses[0].location.state_code)
            mapped = map(
                lambda
                (item): self.__buildRestaurant(city.strip(), state, item),
                results.businesses)
            submissionList.append(mapped)

        for item in submissionList:
            self.__insertRestaurantsForCity(item)
        print "DONE"
def yelp_search():
    # read API keys
    if "consumer_key" in os.environ:
        auth = Oauth1Authenticator(
            consumer_key=os.environ['consumer_key'],
            consumer_secret=os.environ['consumer_secret'],
            token=os.environ['token'],
            token_secret=os.environ['token_secret'])
    else:
        with open('config_secret.json') as cred:
            creds = json.load(cred)
            auth = Oauth1Authenticator(**creds)
            client = Client(auth)

    client = Client(auth)

    params = {'term': request.args.get('category', 'food'), 'lang': 'en'}
    response = client.search('South Bend, IN', **params)
    businesses = response.businesses
    results = {
        b.name: {
            "business_url": b.url,
            "image_url": b.image_url,
            "snippet": b.snippet_text,
            "location": {
                "latitude": b.location.coordinate.latitude,
                "longitude": b.location.coordinate.longitude,
            },
        }
        for b in businesses
    }
    return jsonify(**results)
예제 #3
0
def _scrape_yelp(query):
    client = Client(settings.YELP_AUTH)
    results = client.search('Phoenix', term=query).businesses
    reviews = list(
        map(lambda x: client.get_business(x.id).business.reviews[0].excerpt,
            results))
    return reviews
예제 #4
0
def get_businesses(location, term):
    auth = Oauth1Authenticator(consumer_key=os.environ['CONSUMER_KEY'],
                               consumer_secret=os.environ['CONSUMER_SECRET'],
                               token=os.environ['TOKEN'],
                               token_secret=os.environ['TOKEN_SECRET'])
    client = Client(auth)

    params = {'term': term, 'lang': 'en', 'limit': 3}

    response = client.search(location, **params)
    businesses = []
    #     for business in response.businesses:
    #         # print(business.name, business.rating, business.phone)
    #         businesses.append(business.name)
    #     return businesses
    # businesses = get_businesses('Danville', 'golf')
    # print(businesses)

    # question: what if i want to print out a list of each business as a dictionary
    for business in response.businesses:
        print(business.name, business.rating, business.phone)
        businesses.append({
            "name": business.name,
            "rating": business.rating,
            "phone": business.phone
        })
    return businesses
예제 #5
0
def grab_restaurants(city, offset):
    """grabs business information for the input city
    
    args:
        city   (str): the input city
        offset (int): input value to change the search window for the city
        
    returns: 
        20 restaurants based on the search window for a given city
    """
    
    # set up api call with given keys
    # I followed Yelp's advice to store api information in a json file for privacy
    
    with io.open('config_secret.json') as cred:
        creds = json.load(cred)
        auth = Oauth1Authenticator(**creds)
        client = Client(auth)
        
    # set parameters to search for restuarants in a given offset window
        params = {
        'term': 'restaurant',
        'offset': offset
        }


    return client.search(city, **params)
예제 #6
0
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
예제 #7
0
def getRestaurants(latitude, longitude):
    client = Client(auth)

    params = {'term': 'food', 'lang': 'en', 'radius_filter': 10000}

    response = client.search_by_coordinates(latitude, longitude, **params)
    return response.businesses
예제 #8
0
def get_businesses (location, term, limit):    
    auth = Oauth1Authenticator(
        consumer_key=os.environ['CONSUMER_KEY'],
        consumer_secret=os.environ['CONSUMER_SECRET'],
        token=os.environ['TOKEN'],
        token_secret=os.environ.get('TOKEN_SECRET')
    )

    client = Client(auth)

    
    params = {
        'term': term,
        'lang': 'en',
        'limit': limit
    }

    response = client.search(location, **params)

    # create an empty list named businesses
    businesses = []

    # add things to it.
    for business in response.businesses:
        businesses.append({"name": business.name, "address": business.location.display_address, "rating": business.rating, 'phone': business.display_phone})
    return businesses
예제 #9
0
def search_yelp(input):
    out = []
    with io.open('config_secret.json') as cred:
        creds = json.load(cred)
        auth = Oauth1Authenticator(**creds)
        client = Client(auth)

    params = {
        'term' : input
    }

    client = Client(auth)
    response = client.search('Atlanta', **params)
    print json.dumps(response, default=lambda o: o.__dict__, indent=2)

    for a in response.businesses:
        if a.image_url is None:
            a.image_url = 'http://http.cat/404.jpg'

        try:
            nav_link = ','.join([str(a.location.coordinate.latitude), str(a.location.coordinate.longitude)])
        except AttributeError:
            # print json.dumps(a, default=lambda o: o.__dict__, indent=2)
            nav_link = ''

        out.append([a.name, a.image_url.replace("ms.jpg", "l.jpg"), a.url, a.rating, a.phone, nav_link])
    if (len(out) == 0):
        out.append('No results found')
    return out
예제 #10
0
def search_yelp(secret_file, location, search_parameters):
    # Extract Yelp Data through the API
    import io
    import json
    from yelp.client import Client
    from yelp.oauth1_authenticator import Oauth1Authenticator

    # read API keys
    with io.open(secret_file) as cred:  # Auth in file not shared on github
        creds = json.load(cred)
        auth = Oauth1Authenticator(**creds)
        client = Client(auth)

    # There are three ways to query the Search API: search, search_by_bounding_box, and
    # search_by_coordinates. For each of these methods, additional parameters are optional.
    # The full list of parameters can be found on the Search API Documentation.
    # https://github.com/Yelp/yelp-python

    # search_by_bounding_box takes a southwest latitude/longitude and a northeast
    # latitude/longitude as the location boundary
    response = client.search_by_bounding_box(
        location['sw_latitude'],
        location['sw_longitude'],
        location['ne_latitude'],
        location['ne_longitude'],
        **search_parameters
    )

    return response
예제 #11
0
파일: get_yelp.py 프로젝트: jcallin/eSeMeS
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)
예제 #12
0
def get_businesses(location, term):
    auth = Oauth1Authenticator(
        consumer_key=environ['CONSUMER_KEY'],
        consumer_secret=environ['CONSUMER_SECRET'],
        token=environ['TOKEN'],
        token_secret=environ['TOKEN_SECRET']
    )

    client = Client(auth)

    params = {
        'term': term,
        'lang': 'en',
        'limit': 5
    }

    response = client.search(location, **params)

    businesses = []

    for business in response.businesses:
        # print(business.name, business.rating, business.phone)
        businesses.append({"name": business.name,
            "rating": business.rating,
            "phone": business.phone,
            "address": business.location.address
        })

    return businesses
예제 #13
0
def main():
# read API keys
  with io.open('config_secret.json') as cred:
    creds = json.load(cred)
    session = Oauth1Authenticator(**creds)
    client = Client(session)

  locations = [(40.744, -73.985)]
  api_calls = []

  neighborhood_counter = Counter()
  for lat,lon in locations:
    params = get_search_parameters(lat,lon)
    results = client.search_by_coordinates(lat, lon, **params)

    #Be a good internet citizen and rate-limit yourself
    for b in results.businesses:
      # business fields: 'categories', 'deals', 'display_phone', 'distance', 'eat24_url', 'gift_certificates', 'id', 'image_url', 'is_claimed', 'is_closed', 'location', 'menu_date_updated', 'menu_provider', 'mobile_url', 'name', 'phone', 'rating', 'rating_img_url', 'rating_img_url_large', 'rating_img_url_small', 'reservation_url', 'review_count', 'reviews', 'snippet_image_url', 'snippet_text', 'url'
      print b.name
      print "Street address: %s"%b.location.cross_streets
      print "Neighborhoods: %s"%b.location.neighborhoods
      print b.location.coordinate.latitude, b.location.coordinate.longitude
      neighborhood_counter.update(b.location.neighborhoods)
      # 'address', 'city', 'coordinate', 'country_code', 'cross_streets', 'display_address', 'geo_accuracy', 'neighborhoods', 'postal_code', 'state_code'

    print neighborhood_counter
예제 #14
0
def get_random_bar_coords(lat, lon, radius):
    mpm = 1609.34  # meters per mile
    config = json.load(open('conf.json', 'rb'))

    auth = Oauth1Authenticator(
        consumer_key=config['yelp']['consumer_key'],
        consumer_secret=config['yelp']['consumer_secret'],
        token=config['yelp']['token'],
        token_secret=config['yelp']['token_secret']
    )
    client = Client(auth)

    param_offset = lambda x: {
        'term': 'bars, All',
        'lang': 'en',
        'sort': 2,  # 2: only the top rated in the area
        'radius_filter': int(radius * mpm),
        'offset': x
    }

    bus_list = []
    for offset in [0, 20]:
        response = client.search_by_coordinates(lat, lon, **param_offset(offset))
        bus_list.extend(response.businesses)

    bar = random.choice(bus_list)
    while bar.name in ["Peter's Pub", "Hemingway's Cafe"]:  # Can we just
        bar = random.choice(bus_list)
    return bar.location.coordinate.latitude, bar.location.coordinate.longitude
def call_yelp(midlat,midlong,radius):
	auth = Oauth1Authenticator(
    		consumer_key='Qas4yX9C4dXU-rd6ABmPEA',
    		consumer_secret='5Rtb9Gm5KuwRHSevprdb450E37M',
    		token='xBq8GLMxtSbffTWPPXx7au7EUd2ed3MO',
    		token_secret='Nee0b14NkDO9uSX5cVsS7c4j6GQ'
	)
	print radius
	client = Client(auth)

	params = {
        	'term':'24 hour',
        	'sort':'0',
       		'radius_filter': str(radius) # 3 mi radius
	}

	#ex: response = client.search_by_coordinates(40.758895,-73.985131, **params)
	response = client.search_by_coordinates(float(midlat),float(midlong), **params)

	f = open('output_yelp.txt','w+')

	for i in range(0,len(response.businesses)):
        	#f.write(response.businesses[i].name)
        	#f.write(",")
       	 	f.write('%f' % response.businesses[i].location.coordinate.latitude)
        	f.write(",")
        	f.write('%f' % response.businesses[i].location.coordinate.longitude)
        	f.write("\n")
	f.close()
예제 #16
0
def get_yelp_info(yelp_id):
    origin = request.headers.get('Origin')
    referer = request.headers.get('Referer')

    if origin is None or referer is None:
        return abort(404)

    allowed_url = AllowedUrl.query(AllowedUrl.origin == origin,
                                   AllowedUrl.referer == referer).get()

    if allowed_url is None:
        return abort(404)

    yelp_key = Yelp.query().get()

    if yelp_key is None:
        return abort(404)

    auth = Oauth1Authenticator(consumer_key=yelp_key.consumer_key,
                               consumer_secret=yelp_key.consumer_secret,
                               token=yelp_key.token,
                               token_secret=yelp_key.token_secret)

    client = Client(auth)
    result = client.get_business(yelp_id).business
    response = {}
    response['url'] = result.url
    response['image_url'] = result.image_url
    response['rating_img_url'] = result.rating_img_url

    return jsonify(response)
예제 #17
0
def call_yelp(midlat,midlong,radius):
	auth = Oauth1Authenticator(
    		consumer_key='Qas4yX9C4dXU-rd6ABmPEA',
    		consumer_secret='5Rtb9Gm5KuwRHSevprdb450E37M',
    		token='xBq8GLMxtSbffTWPPXx7au7EUd2ed3MO',
    		token_secret='Nee0b14NkDO9uSX5cVsS7c4j6GQ'
	)
	print radius
	client = Client(auth)

	params = {
        	'term':'24 hour',
        	'sort':'0',
       		'radius_filter': str(radius) # 3 mi radius
	}

	#ex: response = client.search_by_coordinates(40.758895,-73.985131, **params)
	response = client.search_by_coordinates(float(midlat),float(midlong), **params)

	f = open('output_yelp.txt','w+')

	for i in range(0,len(response.businesses)):
        	f.write(response.businesses[i].name)
        	f.write(",")
       	 	f.write('%f' % response.businesses[i].location.coordinate.latitude)
        	f.write(",")
        	f.write('%f' % response.businesses[i].location.coordinate.longitude)
        	f.write("\n")
	f.close()
예제 #18
0
def get_businesses(address):

    auth = Oauth1Authenticator(
        consumer_key=os.environ['YELP_CONSUMER_KEY'],
        consumer_secret=os.environ['YELP_CONSUMER_SECRET'],
        token=os.environ['YELP_TOKEN'],
        token_secret=os.environ['YELP_TOKEN_SECRET'])

    client = Client(auth)

    params = {'term': "food", 'lang': 'en', 'limit': '3'}

    response = client.search(address, **params)

    businesses = []

    for business in response.businesses:
        # print(business.name, business.rating, business.phone)
        businesses.append({
            "name": business.name,
            "rating": business.rating,
            "phone": business.phone,
            "image": business.image_url,
            "stars": business.rating_img_url
        })

    #return("The top 3 recommended resturants for {}, are: {}, {}, and {}".format(address, businesses[0]['name'],
    #businesses[1]['name'], businesses[2]['name']))

    return businesses
예제 #19
0
def get_businesses(location, searchterm):
    auth = Oauth1Authenticator(
        consumer_key=os.environ['CONSUMER_KEY'],
        consumer_secret=os.environ['CONSUMER_SECRET'],
        token=os.environ['TOKEN'],
        token_secret=os.environ['TOKEN_SECRET'],
    )

    client = Client(auth)
    params = {'term': searchterm, 'lang': 'en', 'limit': 3, 'sort': 2}
    #    page_size = 3
    response = client.search(location, **params)

    businesses = []

    for business in response.businesses:
        #print(business.name, business.rating, business.phone)
        businesses.append({
            "name": business.name,
            "rating": business.rating,
            "phone": business.phone
        })
    return businesses


#businesses = get_businesses('Melbourne', 'food')
#print(businesses)
예제 #20
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("output_filename",
                        help="do not include extension (always .json)")
    args = parser.parse_args()

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

    params = {'term': 'food', 'sort': '2'}

    response = client.search('Richmond', **params)
    compactJson = []
    formats = ("id", "name", "rating")
    for bus in response.businesses:
        compacted = {}
        for format in formats:
            compacted[format] = getattr(bus, format)
        compacted["latitude"] = bus.location.coordinate.latitude
        compacted["longitude"] = bus.location.coordinate.longitude
        compactJson.append(compacted)

    jsonDump = json.dumps(compactJson,
                          ensure_ascii=False,
                          sort_keys=True,
                          indent=4)
    with open(args.output_filename + ".json", "w") as f:
        f.write(jsonDump)
예제 #21
0
 def __init__(self, data):
     #authorization
     with io.open('config_secret2.json') as cred:
         creds = json.load(cred)
         auth = Oauth1Authenticator(**creds)
         self.client = Client(auth)
         self.data = data
     self.food_per_business = data['food_per_business']
예제 #22
0
def fetch(location='San Francisco',
          category='private tutors',
          start=0,
          pages=1000):
    client = Client(auth)
    results = []
    i = start
    while i < pages:
        businesses = client.search(location, term=category,
                                   offset=i).businesses
        results.append(businesses)
        print(i)
        if (len(businesses) < 20):
            break
        i += 20

    dicts_to_output = [{
        'Source':
        'Yelp',
        'Position':
        '',
        'Phone':
        biz.display_phone,
        'Yelp_ID':
        biz.id,
        'Yelp_URL':
        biz.url,
        'Business_Name':
        biz.name,
        'Website':
        '',
        'Email':
        '',
        'Individual?':
        '',
        'First_Name':
        '',
        'Last_Name':
        '',
        'Has_booking_on_website?':
        '',
        'Address':
        biz.location.address,
        'City':
        biz.location.city,
        'State':
        biz.location.state_code,
        'Zip_Code':
        biz.location.postal_code,
        'Yelp_Top_Category':
        biz.categories[0].alias if biz.categories else '',
        'Yelp_Review_Count':
        biz.review_count,
        'Yelp_Rating':
        biz.rating
    } for biz in [item for sublist in results for item in sublist]]
    return dicts_to_output
예제 #23
0
def group_recommend(request, event_id):
    try:
        event = Group.objects.get(id=event_id)
    except ObjectDoesNotExist:
        raise Http404

    context = {}

    # if the request user has no relation with the event, redirect to homepage
    if not (request.user == event.user or event.members.filter(user=request.user).exists()):
        return redirect('/linterest/')

    # create a new chatroom associated with event if not already exist
    try:
        chatroom = GroupChatRoom.objects.get(group=event)
    except ObjectDoesNotExist:
        # create a new chatroom w.r.t. the event if not already exist
        chatroom = GroupChatRoom(group=event)

        members = event.members.all();

        chatroom.users.add(Profile.objects.get(user=event.user))

        for member in members:
            chatroom.users.add(member)

        chatroom.save()

    context["event_id"] = event_id
    context["user"] = request.user
    context["type"] = "group"

    with io.open('yelp_secret.json') as cred:
        creds = json.load(cred)
        auth = Oauth1Authenticator(**creds)
        client = Client(auth)
        params = {
            'term': event.type,
            'lang': 'en',
            'limit': 10,
        }
        print('prepare to search')
        try:
            response = client.search(event.city, **params)
        except:
            defaultCoordinate = [40.44, -79.99]
            context['latitude'] = defaultCoordinate[0]
            context['longitude'] = defaultCoordinate[1]
            context['error_message'] = 'Recommendations are unavailable in the given location'
            return render(request, 'recommend.html', context)
        print('search successfully')

        context['latitude'] = response.region.center.latitude
        context['longitude'] = response.region.center.longitude
        context['businesses'] = response.businesses
        return render(request, 'recommend.html', context)
예제 #24
0
    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
예제 #25
0
 def __init__(self, yelp_config):
     self.auth = Oauth1Authenticator(
         consumer_key=yelp_config['consumer_key'],
         consumer_secret=yelp_config['consumer_secret'],
         token=yelp_config['token'],
         token_secret=yelp_config['token_secret'])
     self.client = Client(self.auth)
     self.reader = csv.DictReader
     self.outfile = open('data/yelp/businesses.csv', "w+")
     self.db = []
예제 #26
0
def post_detail(request, photo_id):
    try:
        # get Flickr Post details
        post = FlickrPost.objects.get(pk=photo_id)
        context_dict['valid_post'] = True

        h = html.parser.HTMLParser()

        if not post.latitude or not post.longitude:
            photo = __get_flickr_post_info(photo_id)
            post.latitude = float(photo['location']['latitude'])
            post.longitude = float(photo['location']['longitude'])
            post.description = h.unescape(photo['description']['_content'])
            post.save()

        context_dict['post'] = post

        # get Yelp reviews for that location
        yelp = YelpClient.objects.get(pk=1)
        auth = Oauth1Authenticator(
            consumer_key=yelp.consumer_key,
            consumer_secret=yelp.consumer_secret,
            token=yelp.token,
            token_secret=yelp.token_secret
        )
        client = Client(auth)

        # get location that most closely matches the geolocation
        best_business = None
        alt_businesses = list()
        yelp_api_error = False

        try:
            response = client.search_by_coordinates(post.latitude, post.longitude)

            if response.businesses:
                best_business = response.businesses[0]

                if len(response.businesses) > 5:
                    alt_businesses = response.businesses[1:6]

                elif len(response.businesses) > 1:
                    alt_businesses = response.businesses[1:]

        except:
            yelp_api_error = True

        context_dict['yelp_api_error'] = yelp_api_error
        context_dict['best_business'] = best_business
        context_dict['alt_businesses'] = alt_businesses

    except FlickrPost.DoesNotExist:
        context_dict['valid_post'] = False

    return render(request, 'entree/post_detail.html', context_dict)
예제 #27
0
def Add_nodes(city_name='San_Francisco', buss_type='Restaurants', number=100):
    # Ussing the Yelp library for Yelp authentification and requesting info

    auth = Oauth1Authenticator(consumer_key="",
                               consumer_secret="",
                               token="",
                               token_secret="")

    client = Client(auth)

    buss_types = make_sure('buss_types')

    assert buss_type in buss_types.keys()

    locations = find_locations(city_name, number)

    if os.path.isfile('Data/{}_Data.json'.format(city_name)) == False:
        with open('Data/{}_Data.json'.format(city_name), 'w') as f:
            geojson.dump({"type": "FeatureCollection", "features": []}, f)

    with open('Data/{}_Data.json'.format(city_name)) as f:
        data = json.load(f)

    IDs = []
    added = 0
    nodes_added = []

    for feature in [
            feature for feature in data['features']
            if feature['geometry']['type'] == 'point'
    ]:
        IDs.append(feature['properties']['name'])

    for lat, long in locations:
        places = client.search_by_coordinates(lat, long, buss_type)
        for business in places.businesses:
            if business.name not in IDs:
                IDs.append(business.name)
                node = Node(business.name,
                            business.location.coordinate.latitude,
                            business.location.coordinate.longitude,
                            business.rating,
                            buss_type,
                            business.categories,
                            business.image_url,
                            city_name,
                            comp_time=buss_types[buss_type]['durations'])
                data['features'].append(node.geo_interface())
                nodes_added.append(node)
                added += 1

    with open('Data/{}_Data.json'.format(city_name), 'w') as f:
        geojson.dump(data, f)

    return '{} nodes added'.format(added)
예제 #28
0
def getRestaurants(latitude, longitude):
    client = Client(auth)

    params = {
        'term': 'food',
        'lang': 'en',
        'radius_filter': 10000
    }

    response = client.search_by_coordinates(latitude, longitude, **params)
    return response.businesses
예제 #29
0
    def __init__(self):
        self.name = "yelp"
        creds = self.loadCredentials()

        # Authenticate Yelp
        auth = Oauth1Authenticator(consumer_key=creds["consumer_key"],
                                   consumer_secret=creds["consumer_secret"],
                                   token=creds["token"],
                                   token_secret=creds["token_secret"])
        self.yelpClient = Client(auth)
        self.mongoClient = MongoClient(creds["mongodb"])
예제 #30
0
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
예제 #31
0
def search_food(address):
    auth = Oauth1Authenticator(consumer_key=os.environ['CONSUMER_KEY'],
                               consumer_secret=os.environ['CONSUMER_SECRET'],
                               token=os.environ['TOKEN'],
                               token_secret=os.environ['TOKEN_SECRET'])

    client = Client(auth)

    FORECASTIO_API_KEY = os.environ['FORECASTIO_API_KEY']

    # print("What term are you looking for?")

    # term_input=raw_input()

    # print("And around what address are you looking at?")

    # area=raw_input()

    # print("Looking for {} in {}".format(term_input, area))

    params = {'term': 'bar', 'radius_filter': 1200, 'lang': 'en'}

    response = client.search(address, **params)

    businesses_list = []

    for business in response.businesses:
        if business.rating >= 3.5:
            businesses_list.append({
                "name": business.name,
                "rating": business.rating,
                "phone": business.phone
            })

    # Select a random number from the list of businesses

    rannum = randint(0, len(businesses_list) - 1)
    # print("Cool! Beep boop beep beep boop....")
    # print("calculating...")
    # print("calculating...")
    # print("calculating...")
    # print("Out of {} businesses I am choosing number {}".format(len(businesses_list),rannum))

    # Caclulate weather at random selected resturant
    # def get_address(buisnessname):
    # 	location = geolocator.geocode(buisnessname)
    # 	print(location)

    # Select a random business from the business list, using the random int generated above
    return "Check out {}! \n Phone number is {}".format(
        businesses_list[rannum].get('name'),
        businesses_list[rannum].get('phone'))
예제 #32
0
    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
예제 #33
0
def getResults(entityDict):
    auth = Oauth1Authenticator(consumer_key="GnqVNHo3kMwUkjHtcKTAiQ",
                               consumer_secret="pAAALBgFrBrnfV4wUm4Q-gnRQK0",
                               token="X1adQAiL7lfMu4x0DFLypmDXMJTeR45_",
                               token_secret="6ol3E34GGqZm-rBF-M8U9HsSt7M")

    client = Client(auth)

    LOCATION = entityDict['location']
    CUISINE = entityDict['cuisine']
    COST = entityDict['cost']
    RATING = entityDict['rating']
    DATETIME = entityDict['datetime']

    if (DATETIME):
        HOUR = DATETIME.split('T')[1][0:2]
    else:
        HOUR = ""

    CUISINE = CUISINE if CUISINE else ""
    COST = COST if COST else ""
    RATING = float(RATING) if RATING else 0.0

    params = {
        'term':
        COST + ' ' + CUISINE + ' ' + 'restaurants' + ' which remain open at ' +
        HOUR,
        'sort':
        "0",
        'limit':
        '3'
    }

    if (LOCATION == None):
        return {}

    response = client.search(LOCATION, **params)
    d = {}
    count = 1
    for i in range(0, len(response.businesses)):
        if (response.businesses[i].rating >= RATING):
            d[count] = {}
            d[count]["name"] = response.businesses[i].name
            d[count]["url"] = response.businesses[i].url
            d[count]["address"] = response.businesses[i].location.address
            d[count]["rating"] = response.businesses[i].rating
            d[count]["reviews"] = response.businesses[i].review_count
            count += 1

    return d
def get_total_ratings(x):
    # authenticate the api
    auth = Oauth1Authenticator(
        consumer_key='d8eoj4KNoPqOqE_RN9871Q',
        consumer_secret='pGVDNEGSaH8Kv-WZ8ba5v02IjCo',
        token='S-SfyVte5G0nCkTmbydWRtxlheNXCEnG',
        token_secret='Y_UViE9LthLQqW7_ht8U8V_F6aE'
    )
    client = Client(auth)

    # return the total number of ratings for a restaurant
    total_ratings = client.get_business(x)
    total_ratings = total_ratings.business.review_count
    return total_ratings
예제 #35
0
 def get(self):
     args = parser.parse_args()
     auth = Oauth1Authenticator(consumer_key=consumer_key,
                                consumer_secret=consumer_secret,
                                token=yelp_token,
                                token_secret=yelp_token_secret)
     client = Client(auth)
     response = client.search(**args)
     res = [[
         b.name, b.location.coordinate.latitude,
         b.location.coordinate.longitude, b.rating
     ] for b in response.businesses]
     res = sorted(res, key=lambda x: x[-1], reverse=True)
     return json.dumps(res)
def get_results(params):

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

	request = client.search_by_coordinates("http://api.yelp.com/v2/search",params=params)
	
	#Transforms the JSON API response into a Python dictionary
	data = request.json()
	client.close()
	
	return data
예제 #37
0
def Add_nodes(city_name = 'San_Francisco', buss_type = 'Restaurants' , number = 100):
    # Ussing the Yelp library for Yelp authentification and requesting info


    auth = Oauth1Authenticator(
        consumer_key="",
        consumer_secret="",
        token="",
        token_secret=""
    )
        
    client = Client(auth)

    buss_types = make_sure('buss_types')

    assert buss_type in buss_types.keys()

    locations = find_locations(city_name,number)

    if os.path.isfile('Data/{}_Data.json'.format(city_name)) == False:
        with open('Data/{}_Data.json'.format(city_name),'w') as f:
            geojson.dump({"type": "FeatureCollection","features": []}, f)

    with open('Data/{}_Data.json'.format(city_name)) as f:
            data = json.load(f)

    IDs = []    
    added = 0
    nodes_added = []

    for feature in [feature for feature in data['features'] if feature['geometry']['type'] == 'point']:
        IDs.append(feature['properties']['name'])

    for lat,long in locations:
        places = client.search_by_coordinates(lat, long, buss_type)
        for business in places.businesses:
            if business.name not in IDs:
                IDs.append(business.name)
                node = Node(business.name, business.location.coordinate.latitude, business.location.coordinate.longitude, business.rating,
                            buss_type, business.categories, business.image_url, city_name, comp_time = buss_types[buss_type]['durations'])
                data['features'].append(node.geo_interface())
                nodes_added.append(node)
                added += 1

    with open('Data/{}_Data.json'.format(city_name), 'w') as f:
        geojson.dump(data, f)

    return '{} nodes added'.format(added)
예제 #38
0
def yelp_search():
    client = Client(auth)
    page_size = 20
    page = 0
    count = 0
    max_page_count = 1  # Can take a max value of 50
    search_term = "Parks"
    city = "New York City"

    print("Page: " + str(page + 1) + "\n")
    resp = client.search(term=search_term,
                         location=city,
                         limit=page_size,
                         offset=page * page_size)
    count = count + len(resp.businesses)

    for j in resp.businesses:
        website_link = make_post_requests(j.url)
        if website_link != '0':
            print("Link found.\n")
            links.append([website_link])
        else:
            print("Website link not found.\n")

    while resp and page < max_page_count - 1:
        page = page + 1
        if page % 7 == 0:
            print("\nSleeping for 10 minutes")
            sleep(600)
        print("Page: " + str(page + 1))
        resp = client.search(term=search_term,
                             location=city,
                             limit=page_size,
                             offset=page * page_size)
        count = count + len(resp.businesses)

        for j in resp.businesses:
            website_link = make_post_requests(j.url)
            if website_link != '0':
                print("Link found.\n")
                links.append([website_link])
            else:
                print("Website link not found.\n")
    path = search_term + '.csv'
    with open(path, 'w') as outfile:
        writer = csv.writer(outfile)
        for row in links:
            writer.writerow(row)
예제 #39
0
class yelper:
    def __init__(self):
        with io.open('config_secret.json') as cred:
            creds = json.load(cred)
            auth = Oauth1Authenticator(**creds)
            self.client = Client(auth)

    def resturant_search(self, query):
        try:
            params = {
               'term':'food'
            }
            response = self.client.search(query,**params)
        except Exception as e:
            print(e)
            return None

        data = [0]*5
        for resturant in response.businesses:
            data[int(resturant.rating)-1] +=  1
        """
            data[business.id] = {"coordinates": (business.location.coordinate.latitude, business.location.coordinate.longitude)}
            print(business.categories)
            print()
        """
        return data
예제 #40
0
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'
  });
예제 #41
0
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,
	}
예제 #42
0
파일: services.py 프로젝트: fechu/COS448
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
 def __init__(self):
     auth = Oauth1Authenticator(
             consumer_key= 'NqKErS1dFKKwfxlc5KpB0Q',
             consumer_secret= 'BzO_xc7Jge-B5YeysLuLi-WkiHE',
             token= '72CDWmpOaC8LEVgjY1bZVQgyX4v3v8fx',
             token_secret='yLfQC1-Vr_B5mpuqKtidnK_gnbo'
             )
     self.client = Client(auth)
예제 #44
0
 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)
예제 #45
0
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
예제 #46
0
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
예제 #47
0
파일: services.py 프로젝트: fechu/COS448
    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 = {}
예제 #48
0
 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
예제 #49
0
파일: main.py 프로젝트: geocas38/csgangstas
    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
예제 #50
0
파일: main.py 프로젝트: geocas38/csgangstas
    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
class YelpClient(object):

    def __init__(self):
        auth = Oauth1Authenticator(
                consumer_key= 'NqKErS1dFKKwfxlc5KpB0Q',
                consumer_secret= 'BzO_xc7Jge-B5YeysLuLi-WkiHE',
                token= '72CDWmpOaC8LEVgjY1bZVQgyX4v3v8fx',
                token_secret='yLfQC1-Vr_B5mpuqKtidnK_gnbo'
                )
        self.client = Client(auth)

    def search(self,params):
        return self.client.get_business(params)
예제 #52
0
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)
예제 #53
0
 def findScheduleOptions(self):
     self.options_list = []
     #Create a pair of activities for each of the combinations of one result from yelp and one from eventful
     for an_event in self.eventful_results:
         event_activity = Activity(an_event, "eventful")
         
         lat = an_event['latitude']  #
         lng = an_event['longitude']  #
         dining_activities = []
 
         auth = Oauth1Authenticator(consumer_key = "mvC1SY7wAUx_RPlVhG-fIw",consumer_secret = "vkqWVoowxsWkUu7KU0t2Pj3qY1k",token =  "syYEIdwvGt-uLGdgVmu9ZsQfE98CROe4", token_secret = "AQLQnKJA7VYw4XlVIMK7hYzSwDo") #
         client = Client(auth)  #
         
         print("yelp params", self.yelp_params)
         
         yelp_results = client.search_by_coordinates(lat, lng, **self.yelp_params)
         print(len(yelp_results.businesses))
         for j in range(len(yelp_results.businesses)):
             #print(location.businesses[j])
             #print(self.yelp_results.businesses[j])
             dining = Activity(yelp_results.businesses[j], "yelp")
             dining_activities.append(dining)
         self.options_list.append(EventAndDiningPair(event_activity, dining_activities))
예제 #54
0
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	 
예제 #55
0
파일: app.py 프로젝트: Somtida/DecideR
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
예제 #56
0
파일: api.py 프로젝트: fhacktory/Pokemon69
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
예제 #57
0
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
# cell 1 - crtea Yelp client based on your keys

from yelp.client import Client
from yelp.oauth1_authenticator import Oauth1Authenticator

auth = Oauth1Authenticator(
    consumer_key="[your customer kwy]",
    consumer_secret="[your customer secret]",
    token="[your token]",
    token_secret="[your token secret]"
)

client = Client(auth)


# cell 2 - TYR1: try to find whether Yelp search is based on key words in current business content

params = {
    'term': 'Pokemon'
}
response = client.search('Seattle', **params)

ct = 0
for biz in response.businesses:
  print biz.name
  print biz.id
  print biz.image_url
  print biz.categories
  print biz.rating
  print biz.reviews
  
import json

from yelp.client import Client
from yelp.oauth1_authenticator import Oauth1Authenticator

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

#terms= ['KFC']
#for term in terms:
params = {
	'terms': 'parks, all',
  'lang': 'en',
  'sort': '1',    		
  'radius_filter':'40000',	
}
response = client.search('San Francisco', **params)

bizlist=response.businesses
for biz in bizlist:
    print biz.url