Exemplo n.º 1
0
client = Client(auth)


print "Start"

columns = ['phone','name', 'review_count', 'categories','rating']


new = []
j = 0

for i in df['SearchPhone'][:5000]:
    print i, j, j/5000.0
    try:
        response = client.phone_search("'" + str(i) + "'")
        new.append([response.businesses[0].phone
                ,response.businesses[0].name
                ,response.businesses[0].review_count
                ,response.businesses[0].categories
                ,response.businesses[0].rating])
    except IndexError:
        new.append([str(i),"","","",""])
    else:
        new.append([str(i),"","","",""])
    j += 1
        
df2 = pd.DataFrame(new)

        
df2.to_csv("Yelp5000.csv", index=False, header=False)
Exemplo n.º 2
0
auth = Oauth1Authenticator(consumer_key='XXXXXXXXXXXXXXXXXXXXXX',
                           consumer_secret='XXXXXXXXXXXXXXXXXXXXXXXXXXX',
                           token='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
                           token_secret='XXXXXXXXXXXXXXXXXXXXXXXXXXX')

client = Client(auth)

phones = []
phone_file = sys.argv[1]
with open(phone_file, 'r') as fh:
    for line in fh:
        line = line.rstrip()
        if len(line) == 12:
            phones.append(line)

responses = []
for i, phone in enumerate(phones):

    try:
        #print i+1
        response = client.phone_search(phone)
        if len(response.businesses) > 0:
            biz = response.businesses[0]
            catg = biz.categories[0].alias if biz.categories else ''
            print('%s\t%s\t%s\t%s\t%s\t%s' %
                  (biz.name, biz.id, catg, biz.rating, biz.review_count,
                   biz.phone))
    except:
        pass
	'sort':2
}

a=client.search('341+West+Tudor+Road+Anchorage+AK+99503', **params)
a.businesses
for item in a.businesses:
    print item.name, item.rating, item.review_count
				

b = client.get_business('', **params)

"city": "Anchorage", "zip": "99503", "phone": "9077706652", "state": "AK", "address_2": "Suite 101", "address": "341 West Tudor Road"



b = client.get_business('Makar', **params)
a.businesses    
for item in a.businesses:
    print item.name, item.rating, item.review_count
    
    
params = {
    'category': 'health'
}

c = client.phone_search('+19077706652', **params)
c.businesses  
for item in c.businesses:
    print item
for item in c.businesses:
    print item.name, item.rating, item.review_count