Skip to content

Instantly share code, notes, and snippets.

@zokis
Created July 17, 2015 13:56
Show Gist options
  • Save zokis/7ec314eef750562f6f3b to your computer and use it in GitHub Desktop.
Save zokis/7ec314eef750562f6f3b to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# -*- coding: utf-8 -*-
import facebook
import requests
import json
my_token = 'tkn'
graph = facebook.GraphAPI(access_token=my_token)
me = graph.get_connections('1005327179519367', 'comments')
f = open('arquivo.txt', 'a')
f.write('[')
while True:
try:
json.dump(me, f, indent=4)
f.write(',')
me = requests.get(me['paging']['next']).json() # chama a proxima pagina de comentários
except KeyError:
# When there are no more pages (['paging']['next']), break from the
# loop and end the script.
f.close
break
f.write('{}]')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment