[Python] Download all posts with likes and comments of those posts at the same time using the...

Discussão em 'Python' iniciado por Stack, Outubro 7, 2024.

  1. Stack

    Stack Membro Participativo

    I am trying to download all the posts and the comments (and replies to comments) for that post in a public Facebook page. Here is the code that I am using:

    from facepy import GraphAPI
    import json

    page_id = "Google"
    access_token = "access_token"

    graph = GraphAPI(access_token)

    data = graph.get(page_id + "/feed", page=True, retry=3, limit=100,fields='message,likes')


    i = 0
    for p in data:
    print 'Downloading posts', i
    with open('facepydata/content%i.json' % i, 'w') as outfile:
    json.dump(p, outfile, indent = 4)
    i += 1


    First of all (1) this code is giving me this exception:
    facepy.exceptions.FacebookError: [1] Please reduce the amount of data you're asking for, then retry your request
    How should I solve this problem?
    Second: (2) How can I get all the likes, comments and replies at the same time of getting the posts (paging is also required in likes, comments and replies to get all of them). page=True not working for these fields.

    Continue reading...

Compartilhe esta Página