2017-03-19 28 views

回答

1

你可以使用在線服務,如SociographGrytics來獲取數據,甚至導出它們(我試過sociograph)。

如果您想自己下載數據,那麼您需要構建一個程序,通過圖形API爲您獲取數據,然後您可以根據自己的數據做任何事情。

這裏是一個簡單的我砍了python從facebook組中獲取數據。 使用這種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) 基本上使用圖形的API,你可以得到你需要了解該組的所有信息,如每個帖子喜歡,誰喜歡什麼,數視頻,照片等,並從那裏扣除。

我GOOGLE了,但找不到這個bash腳本。

+0

太好了,謝謝! –