简体   繁体   中英

How can I get more than five thousand members from a Facebook group using facepy, graphAPI and Python 3.5

I am trying to retrieve a list of all users of a fairly large Facebook group (just over ten thousand members). However, the script stops downloading just before five thousand members. I don't get any error messages, so I now wonder if my code is wrong or if Facebook has a limit (without giving errors) that I keep hitting? Here is my code:

from facepy import GraphAPI
from django.core.serializers.json import DjangoJSONEncoder
import json

group_id =""
access_token = ""

graph = GraphAPI(access_token)
# "limit" can be altered, but won't change how much I can download
pages = graph.get(group_id + "/members", page=True, retry=3, limit=10000) 
i = 0
for p in pages:
    print('Downloading page', i)
    with open('%scontent%i.json' % (group_id, i), 'w') as outfile:
        json.dump(p, outfile, indent = 4, cls=DjangoJSONEncoder, ensure_ascii=False)
    i += 1

There is an old bug about this: https://developers.facebook.com/bugs/267362886791339/

As you can see, it is a well known bug, but Facebook will not fix it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM