Created
July 17, 2015 13:56
-
-
Save zokis/7ec314eef750562f6f3b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/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