Search code examples
bashfacebookdownloadcommand-line-interface

Any way to download a Facebook group?


Sorry for a strange question. I'm an admin of a very useful Facebook group. There is a lot of valuable info, which I'd like to have offline. Is there any (cli) method to download it?


Solution

  • You could use online services like Sociographand Grytics to get data and even export them(I tried sociograph).

    If you want to download the data yourself, then you need to build a program that gets the data for you through the graph api and from there you can do whatever you want with the data you get.

    Here is a simple I hacked in python to get the data from a facebook group. Using this SDK

    #!/usr/bin/env python3
    
    import requests
    import facebook
    from collections import Counter
    
    graph = facebook.GraphAPI(access_token='fb_access_token', version='2.7', timeout=2.00)
    posts  = []
    
    
    post = graph.get_object(id='{group-id}/feed') #graph api endpoint...group-id/feed
    group_data = (post['data'])
    
    all_posts = []
    
    """
     Get all posts in the group.
    """
    def get_posts(data=[]):
        for obj in data:
            if 'message' in obj:
                print(obj['message'])
                all_posts.append(obj['message'])
    
    
    """
    return the total number of times each word appears in the posts
    """
    def get_word_count(all_posts):
        all_posts = ''.join(all_posts)
        all_posts = all_posts.split()
        for  word in all_posts:
            print(Counter(word))
    
        print(Counter(all_posts).most_common(5)) #5 most common words
    
    
    
    """
    return number of posts made in the group
    """
    def posts_count(data):
        return len(data)
    

    get_posts(group_data) get_word_count(all_posts) Basically using the graph-api you can get all the info you need about the group such as likes on each post, who liked what, number of videos, photos etc and make your deductions from there.

    I googled but couldn't find a bash script for this.