Exemple #1
0
def search(lat, lng, distance):
    """
    Searches the Foursquare API (Max Limit = 50)

    :param lat: Latitude of the request
    :param long: Longitude of the request
    :param distance: Distance to search (meters)
    :returns: List of retrieved venues
    """

    url = SEARCH_URL.format(lat, lng, distance,
                            CATEGORY_ID, CLIENT_ID, CLIENT_SECRET,
                            time.strftime("%Y%m%d"))
    venue_list = []

    try:
        data = make_request(url)

        for item in data['response']['groups'][0]['items']:
            venue = item['venue']
            venue_list.append(Business(venue['name'],
                                       venue['location']['address'],
                                       venue['rating'],
                                       venue['ratingSignals'],
                                       venue['stats']['checkinsCount']))
    except Exception, e:
        print e
Exemple #2
0
def search(lat, lng, distance):
    """
    Searches the Foursquare API (Max Limit = 50)

    :param lat: Latitude of the request
    :param long: Longitude of the request
    :param distance: Distance to search (meters)
    :returns: List of retrieved venues
    """

    url = 'https://api.foursquare.com/v2/venues/explore?ll=%s,%s&intent=browse&radius=%s&limit=50&categoryId=%s&client_id=%s&client_secret=%s&v=%s' % (
        lat, lng, distance, CATEGORY_ID, CLIENT_ID, CLIENT_SECRET,
        time.strftime("%Y%m%d"))
    venue_list = []

    try:
        data = make_request(url)

        for item in data['response']['groups'][0]['items']:
            venue = item['venue']
            venue_list.append(
                Business(venue['name'], venue['location']['address'],
                         venue['rating'], venue['ratingSignals'],
                         venue['stats']['checkinsCount']))
    except Exception, e:
        print e
Exemple #3
0
def search(lat, lng, distance):
    """
    Searches the Foursquare API (Max Limit = 50)

    :param lat: Latitude of the request
    :param long: Longitude of the request
    :param distance: Distance to search (meters)
    :returns: List of retrieved venues
    """

    url = SEARCH_URL.format(lat, lng, distance, CATEGORY_ID, CLIENT_ID,
                            CLIENT_SECRET, time.strftime("%Y%m%d"))
    venue_list = []

    try:
        data = make_request(url)

        for item in data['response']['groups'][0]['items']:
            venue = item['venue']
            venue_list.append(
                Business(venue['name'], venue['location']['address'],
                         venue['rating'], venue['ratingSignals'],
                         venue['stats']['checkinsCount']))
    except Exception, e:
        print e
Exemple #4
0
def search_place(place_id):
    """
    Searches Google for a specific Place

    :param id: Google Place ID
    :returns: Business object
    """

    url = PLACE_URL.format(place_id, GOOGLE_API_KEY)

    try:
        data = make_request(url)

        place = data['result']
        return Business(place['name'],
                        place['formatted_address'].split(',')[0],
                        place['rating'], place['user_ratings_total'], 'N/A')
    except Exception, e:
        print e
Exemple #5
0
def search(lat, lng, distance):
    """
    Searches the Google Places API (Max Limit = 20)

    :param lat: Latitude of the request
    :param long: Longitude of the request
    :param distance: Distance to search (meters)
    :returns: List of retrieved places
    """

    url = SEARCH_URL.format(lat, lng, distance, GOOGLE_API_KEY)
    place_list = []

    try:
        data = make_request(url)

        for result in data['results']:
            place = search_place(result['place_id'])
            place_list.append(place)

    except Exception, e:
        print e
Exemple #6
0
def search_place(place_id):

    """
    Searches Google for a specific Place

    :param id: Google Place ID
    :returns: Business object
    """

    url = PLACE_URL.format(place_id, GOOGLE_API_KEY)

    try:
        data = make_request(url)

        place = data['result']
        return Business(place['name'],
                        place['formatted_address'].split(',')[0],
                        place['rating'],
                        place['user_ratings_total'],
                        'N/A')
    except Exception, e:
        print e
Exemple #7
0
def search(lat, lng, distance):
    """
    Searches the Google Places API (Max Limit = 20)

    :param lat: Latitude of the request
    :param long: Longitude of the request
    :param distance: Distance to search (meters)
    :returns: List of retrieved places
    """

    url = SEARCH_URL.format(lat, lng, distance, GOOGLE_API_KEY)
    place_list = []

    try:
        data = make_request(url)

        for result in data['results']:
            place = search_place(result['place_id'])
            place_list.append(place)

    except Exception, e:
        print e