Skip to content

Instantly share code, notes, and snippets.

@chribsen
Created March 21, 2016 13:25
Show Gist options
  • Save chribsen/e62b6ccc26f113d285ce to your computer and use it in GitHub Desktop.
Save chribsen/e62b6ccc26f113d285ce to your computer and use it in GitHub Desktop.
Retrieves places in 10km vicinity to Roskilde Festival and stores it in a JSON file.
import requests, json
import time
# Places token
token = '<my_token>'
params = {'access_token': token,
'center': ','.join([str(55.622534), str(12.080729)]),
'distance': 10000,
'type': 'place',
}
data = []
r = requests.get('https://graph.facebook.com/v2.5/search', params=params)
response = r.json()
data += response['data']
while response['paging'].get('next'):
next_url = response['paging']['next']
time.sleep(1)
r = requests.get(next_url)
response = r.json()
print(json.dumps(response, indent=2))
data += response['data']
print('places: ' + str(len(data)))
f = open('places_fb_10km.json', 'w')
f.write(json.dumps(data, indent=2))
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment