예제 #1
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
예제 #2
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)
예제 #3
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
예제 #4
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
예제 #5
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"
예제 #6
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
예제 #7
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)
예제 #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
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
예제 #10
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
예제 #11
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)
예제 #12
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
예제 #13
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)
예제 #14
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)
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)
예제 #16
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
예제 #17
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)
예제 #18
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
예제 #19
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
예제 #20
0
def get_yelp_restaurants():

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

    # query
    final_result = []

    params = {
        'term': 'restaurants',
        'offset': 0,
    }

    search_results = client.search('Southampton', **params)
    for r in search_results.businesses:
        mydata = {}
        mydata['name'] = r.name
        mydata['rating'] = r.rating
        mydata['review_count'] = r.review_count
        mydata['categories'] = r.categories
        mydata['latitude'] = r.location.coordinate.latitude
        mydata['longitude'] = r.location.coordinate.longitude
        final_result.append(mydata)


    while search_results and params['offset'] < 840:
        params['offset'] += 20
        search_results = client.search('Southampton', **params)
        for r in search_results.businesses:
            mydata = {}
            mydata['name'] = r.name
            mydata['rating'] = r.rating
            mydata['review_count'] = r.review_count
            mydata['categories'] = r.categories
            mydata['latitude'] = r.location.coordinate.latitude
            mydata['longitude'] = r.location.coordinate.longitude
            final_result.append(mydata)

    return final_result
예제 #21
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
예제 #22
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'))
예제 #23
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
예제 #24
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
예제 #25
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)
예제 #26
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
예제 #27
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'
  });
예제 #28
0
def get_category(mcategory):
    auth = Oauth1Authenticator(consumer_key=settings.CONSUMER_KEY,
                               consumer_secret=settings.CONSUMER_SECRET,
                               token=settings.TOKEN,
                               token_secret=settings.TOKEN_SECRET)

    client = Client(auth)
    offset = 0

    while True:
        params = {'category_filter': mcategory, 'offset': offset}
        try:
            response = None
            response = client.search(settings.CITY, **params)
        except InvalidParameter:
            all_categories[mcategory] = -1
            break
        print '{} {} {}'.format(params, len(response.businesses),
                                response.total)
        for business in response.businesses:
            try:
                categories = [
                    category.alias for category in business.categories
                ]
            except TypeError:
                continue
            if settings.RECURSE_CATEGORIES:
                for category in categories:
                    if category.lower().replace(" ", "") not in all_categories:
                        all_categories[category.lower().replace(" ", "")] = 0
            with open('output/businessdata.csv', 'a') as outfile:
                try:
                    outfile.write(
                        '"{0}"|"{1}"|"{2}"|"{3}"|"{4}"|"{5}"|"{6}"|"{7}"|"{8}"|"{9}"|"{10}"\n'
                        .format(business.id, business.name, ', '.join(
                            sorted(categories)), business.review_count,
                                business.rating, business.url, business.phone,
                                ', '.join(business.location.address),
                                business.location.city,
                                business.location.state_code,
                                business.location.postal_code))
                except UnicodeEncodeError:
                    pass
        offset += 20
        if len(response.businesses) < 20:
            all_categories[mcategory] = 1
            break
예제 #29
0
def busines_locatons(term, location):
    auth = Oauth1Authenticator(consumer_key="mUp8NqSZCv9WvRZZb2yVcw",
                               consumer_secret="oofNJJKjpU4HVOCksIOeknjT1nM",
                               token="tGdfkcrrJY6rL_8o_KmGkF9zy0PwTVaW",
                               token_secret="anbTo3CXxHdZMOTP5L-VV9L2EoU")

    client = Client(auth)

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

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

    for business in response.businesses:
        print(business.name)
예제 #30
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
예제 #31
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
예제 #32
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,
	}
예제 #33
0
파일: yelp_api.py 프로젝트: hlxkl/flask
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'}

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

    businesses = []

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

    return businesses
예제 #34
0
    def _yelpPlaceGet(self, keyStr=None):
        yelp_places = Client(auth)
        params["term"] = keyStr
        response = yelp_places.search("seattle", **params)

        pp = pprint.PrettyPrinter(indent=4)

        datadict = []
        for result in response.businesses:
            data = {
                "name": str(result.name),
                "phone": str(result.phone),
                "url": str(result.url)
            }
            datadict.append(data)

        pp.pprint(datadict)
        return datadict
예제 #35
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)
예제 #36
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
예제 #37
0
파일: main.py 프로젝트: alainasd/Learning
    def get(self):
        title = request.args.get('title')

        creds = json.loads(open('yelp_secrets.json', 'r').read())
        auth = Oauth1Authenticator(**creds)
        yelp_client = Client(auth)

        params = {'term': title}

        res = yelp_client.search('San Francisco', **params)
        if not res.businesses:
            return jsonify({'status': 'ERROR', 'msg': 'No results found'})

        biz = res.businesses[0]

        biz_item = dict(phone=biz.phone,
                        rating_img_url=biz.rating_img_url,
                        snippet=biz.snippet_text)
        return jsonify({'status': 'OK', 'biz': biz_item})
예제 #38
0
def get_businesses(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)

    params = {'term': "beer", '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})

    return businesses
예제 #39
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
예제 #40
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)
예제 #41
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
예제 #42
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
예제 #43
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
예제 #44
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
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
  
  print biz.location.address
  print biz.location.display_address  # full address
  print biz.location.cross_streets
  print biz.location.neighborhoods
  print biz.location.coordinate.latitude
예제 #46
0
파일: tester.py 프로젝트: bourdakos1/Fetch
true_count = 0
false_count = 0
count = 0
for result in results:

    count += 1
    update_progress(count/total*100)

    exp_answer = result[0]
    answer = result[1]

    params = {
        'term': answer
    }
    response = client.search('Pittsburgh', **params).businesses
    if len(response) > 0:
        response = response[0]
    else:
        if answer == exp_answer:
            true_count += 1
        else:
            false_count += 1
        continue
    name = response.name.lower()

    params = {
        'term': exp_answer
    }
    exp_response = client.search('Pittsburgh', **params).businesses[0]
    exp_name = exp_response.name.lower()
예제 #47
0
import io
import sys
import json
from yelp.client import Client
from yelp.errors import InvalidParameter
from yelp.oauth1_authenticator import Oauth1Authenticator

with io.open('config_secret.json') as cred_file:
	creds = json.load(cred_file)
	auth = Oauth1Authenticator(**creds)
	client = Client(auth)

params = {
	'term': 'food',
	'lang': 'fr'
}

try:
	response = client.search('San Francisco')
except InvalidParameter as e:
	print "Client error: ", e.text
	exit(1)

print repr(response)
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

예제 #49
0
import json
from yelp.client import Client
from yelp.oauth1_authenticator import Oauth1Authenticator


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

params = {
    'category_filter': 'french',
    'term': 'food',
    'limit': 5
}

result = client.search('San Francisco', **params)
print result


print result.businesses[-2].name
print result.businesses[-2].rating
print result.businesses[-2].categories
print result.businesses[-2].location.display_address
print result.businesses[-2].location.cross_streets
예제 #50
0
  "term": "Restaurants",
  "sort": 2,
  "limit": 10,
  "category_filter": "japanese"
  #"location": "Convoy Street, San Diego, CA 92111"
}

params_7 = {
  "term": "Restaurants",
  "sort": 2,
  "limit": 10,
  "category_filter": "chinese"
  #"location": "Convoy Street, San Diego, CA 92111"
}

response = client.search("Convoy Street, San Diego, CA 92111", **params_7)
response_2 = client.search("Convoy Street, San Diego, CA 92111", **params_2)
for i in range(0, len(response.businesses)):
  print(response.businesses[i].name)

"""
with open(output, 'w') as out:
  out.write('[')
  convoy = dict()
  convoy['isExpandable'] = True
  convoy['isExpanded'] = False
  convoy['isVisible'] = True
  convoy['label'] = 'Convoy'
  convoy['checked'] = 1
  convoy['cellIdentifier'] = 'idCategoryCell'
  convoy['additionalRows'] = 40
예제 #51
0
def main():
	
	ai = apiai.ApiAI(CLIENT_ACCESS_TOKEN, session_id = session)
	request = ai.text_request()
	request.language = 'en'

	inp = input('Describe what kind of a place you would like to go to!')

	request.query = inp

	response_api = request.getresponse()

	rstr = response_api.read().decode('utf-8')
	json_obj = json.loads(rstr) 
	result = json_obj.get('result')
	incomplete = result.get('actionIncomplete')
	speech = result.get('fulfillment').get('speech')
	
	
	if result.get('actionIncomplete') == False:

		params = result.get('parameters')
		rtype = params.get('type')
		rcity= params.get('geo-city')
		rplace = params.get('place')
		rrank = params.get('rank')



	else:
		while result.get('actionIncomplete') == True:
			if result.get('actionIncomplete') == True:	
				ai = apiai.ApiAI(CLIENT_ACCESS_TOKEN, session_id = session)
				new_request = ai.text_request()
				new_request.language = 'en'

				new_inp = input(speech)

				new_request.query = new_inp

				new_response_api = new_request.getresponse()

				new_rstr = new_response_api.read().decode('utf-8')
				new_json_obj = json.loads(new_rstr) 
				result = new_json_obj.get('result')
				speech = result.get('fulfillment').get('speech')
				params = result.get('parameters')
				rtype = params.get('type')
				rcity= params.get('geo-city')
				rplace = params.get('place')
				rrank = params.get('rank')


	rparams= [rtype, rcity, rplace, rrank]
	rrparams = rtype + '+'+ rplace + '+' + rcity 	
	if rrank != '':
		rrparams = rtype + '+'+ rplace + '+' + rcity + '+' + rrank
	srch = rrparams
	
	google_list=google_place_search( srch )
	
	auth = Oauth1Authenticator(
		consumer_key=YELP_CONSUMER_KEY,
		consumer_secret=YELP_CONSUMER_SECRET,
		token=YELP_TOKEN,
		token_secret=YELP_TOKEN_SECRET
		)
	client_yelp = YelpClient(auth)
	yelp_params = {
	'term': rtype, 
	'category': rplace,
	'lang': 'en'
	}
	
	matches = []
	for obj in client_yelp.search(rcity, rrank,**yelp_params).businesses:
			matches.append(obj.name)
	
	 
	print('Yelp: ')
	for m in matches:
		
		print(m)		
	
	google_list = [item.lower() for item in google_list]
	matches = [match.lower() for match in matches]
	same = []
	for place in google_list:
		if place in matches:
			same.append(place)
	
	same = [sa.title() for sa in same]
	print('\n')
	print('Same: ')
	for q in same:
		print(q)

	print('\n')
	print ('Different: ')	
	different = []
	for place in google_list:
		if place not in matches:
			different.append(place)
	for place in matches:
		if place not in google_list:
			different.append(place)
	different = [elm.title() for elm in different]		
	for el in different:		
		print(el)		
    token="ec7SmRYyo8kAR6wNgeHwOTvITzC1jYAi",
    token_secret="Uu9qBWo7olB6lmp2nsQ9g0xHSPE"
)

client = Client(auth)

#look for Montreal restaurants
#english reviews


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

response = client.search('Montreal', **params)

#get their ID

####response.businesses[0].id

print(response.businesses[0].id)

str1 = str(response.businesses[0].id)

#get reviews for this business-id

params_b = {
         'lang' : 'en'
    }
예제 #53
0
import json

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

# Limit API request to 20 results first
# Keep database small, until something working to make another API request
params = {
    'term': 'food',
    'limit': 20,
}

response = client.search('Sunnyvale', **params)

# API response returns a SearchResponse object
# Specify information by looking at its attributes and indexing

for business in response.businesses:
    print "------RESTAURANT----------"
    print "Business Name: ", business.name
    print "Business Image: ", business.image_url
    print "Address: ", " ".join(business.location.display_address)
    print "Phone Number: ", business.display_phone
    print "Latitude: ", business.location.coordinate.latitude
    print "Longitude: ", business.location.coordinate.longitude
    print "Categories: "
    for category in business.categories:
        print category.name
예제 #54
0
    }
    return section

def create_item(name, description, price):
    item = {
        'name': name,
        'description': description,
        'price': price
    }
    return item

params = {
    'term': subject
}

businesses = client.search('Pittsburgh', **params).businesses

menu_object = ''
for business in businesses:
    provider = business.menu_provider
    if provider:
        menus['name'] = business.name
        menus['logo'] = business.image_url
        menus['stars'] = business.rating
        menus['reviews'] = business.review_count

        name = quote(business.name)

        locu_key = '705dd0bae9197fd1ea36912f49473722092639c4'
        foursquare_id = 'YGL0AT5G1Y3NDAD34DUWL5RV00SDLGZHSS0YSLG24TDHZBWH'
        foursquare_secret = 'TSKVWGPB2PBR34XZ0WC3RT50YZH1SUZUARUXAV2YFMPFURZS'
예제 #55
0
client = Client(auth)

#Grab cities with "food" in the above cities
city_resps = defaultdict(object)

params = {
    'category': 'venues',
    'lang': 'en',
    'location': None,
    'term': 'venue'
}

for city in cities:
    params['location'] = "%s, Illinois" % city
    resp = client.search(**params)
    city_resps[city] = resp


# In[110]:

import re
def images(url):
    url = re.sub('\?.*','',url)
    url = re.sub('/biz/','/biz_photos/',url)
    print url

all_venues = []
for city, search in city_resps.items():
    city_business = [ {'address':'|'.join(b.location.address),
                       'city':b.location.city,
예제 #56
0
    zips = zipstr.split(', ')

    params = {
            'lang': 'en',
            'sort': 0  #Sort mode: 0=Best matched (default), 1=Distance, 2=Highest Rated
           #'limit': 20   limit can be 1 to 20
           #'offset': 21  we will use this parameter later in the loop
    }

    results = []

    for zipcode in zips:
        for i in range(50):
            n = i * 20 + 1
            params['offset'] = n
            response = client.search(zipcode, **params)
            bizs = response.businesses
            for biz in bizs:
                b = vars(biz)
                b['location'] = vars(biz.location)
                b['location']['coordinate'] = vars(biz.location['coordinate'])
                results.append(b)
            break
                                
            if len(response.businesses) < 20:
                break
            else:
                continue

    '''
    with open('my_boston_restaurants_yelp.json', 'wb') as f:
예제 #57
0
	# Each line is a separate search
	for line in f:

		# Start again at first column
		colNum = 1

		# Strip whitespace
		line_search = line.strip()

		# Search parameters
		params = {
		    'term': line_search,
		}

		# Yelp Search API
		response = client.search(location, **params)

		try:
			# First result
			business = response.businesses[0]

			name = business.name
			rating = business.rating
			review_count = business.review_count
			address_list = business.location.address
			# http://stackoverflow.com/questions/18272066/easy-way-to-convert-a-unicode-list-to-a-list-containing-python-strings
			address_encoded = [x.encode('UTF8') for x in address_list]
			# http://stackoverflow.com/questions/5618878/how-to-convert-list-to-string
			address = ' '.join(address_encoded)
			city = business.location.city
			state = business.location.state_code
    consumer_secret=csecret,
    token=ytoken,
    token_secret=ytokensecret
)

yelpClient = Client(yelpAuth)

repo.dropPermanent("pharmacy")
repo.createPermanent("pharmacy")

params= {
		'term': 'pharmacy',
		'location': "02115"
	}

R = yelpClient.search(**params)

# store businesses in 

pharm = []

for r in R.businesses:
	pharm_name = r.name
	pharm_lat = r.location.coordinate.latitude
	pharm_lon = r.location.coordinate.longitude
	pharm_zipcode = r.location.postal_code
	pharm_city = r.location.city
	pharm_neigh = r.location.neighborhoods # multiple possible
	pharm_street = r.location.address[0]
	pharm_fulladdress = ", ".join(r.location.display_address)
	pharm_phone = r.phone
예제 #59
0
파일: helloyelp.py 프로젝트: zanph/zanph
import io
import json
from yelp.client import Client
from yelp.oauth1_authenticator import Oauth1Authenticator

with io.open('yelp_config_secret.json') as cred:
    creds = json.load(cred)
    auth = Oauth1Authenticator(**creds)
    client = Client(auth)

params = {
    'term': 'food',
    'lang': 'fr'
}

response = client.search('Chicago',**params)
print response