Created
May 6, 2014 01:13
-
-
Save desg/fc25324cf713fe08beb5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from requests_oauthlib import OAuth1 | |
import random | |
#API information | |
consumer_key = "" | |
consumer_secret = "" | |
token = "" | |
token_secret = "" | |
# Write Better Version of this | |
foodsURL = "http://api.yelp.com/v2/search?" | |
term = "food" | |
radius_filter ="16100" | |
location = "Atlanta" | |
payload = {'term': term, 'radius_filter': radius_filter, 'location': location} | |
def yelpRequest(hostURL, payload, consumer_key, consumer_secret, token, token_secret): | |
auth = OAuth1(consumer_key, consumer_secret, | |
token, token_secret) | |
con = requests.get(hostURL, params=payload, auth=auth).json() | |
return con | |
response = yelpRequest(foodsURL, payload, consumer_key, consumer_secret, token, | |
token_secret) | |
foodlist = [] | |
for i in range(0, len(response['businesses'])): | |
foodlist.append(response['businesses'][i]#['name'].encode('utf_8')) | |
print random.choice(foodlist) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment