【问题标题】:Scraping posts to a Facebook group using Python?使用 Python 将帖子抓取到 Facebook 群组?
【发布时间】:2021-12-29 15:06:07
【问题描述】:

我正在尝试从 Facebook 群组中提取所有帖子。我按照 2017 年帖子中的示例安装了 facepy:

import csv
from datetime import datetime
from facepy import GraphAPI
import json

APP_TOKEN = r'XXXMYTOKENXXX'

graph = GraphAPI(APP_TOKEN)

groupIDs = ("2208833392") #https://www.facebook.com/groups/TheEntomologyGroup/ has Facebook Group ID 2208833392

now = datetime.now() # current date and time
date_time = now.strftime("%Y%m%d%H%M%S")

outfile_name = date_time+"TheEntomologyGroup.csv"
f = csv.writer(open(outfile_name, "wb+"))

for gID in groupIDs:
    groupData = graph.get(gID + "/feed", page=True, retry=1, limit=500)

    for data in groupData:
        json_data=json.dumps(data, indent = 4,cls=DecimalEncoder)
        decoded_response = json_data.decode("UTF-8")
        data = json.loads(decoded_response)
        print("Paging group data...")

        for item in data["data"]:
            print(item)

...但我得到一个错误:

FacebookError: [100] Unsupported get request. Object with ID '2' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api

问题:

  1. facepy 仍然是用于这种类型的最好/最简单的库吗? 东西?
  2. 我做错了什么?有什么建议吗?

【问题讨论】:

    标签: python facebook-graph-api facepy


    【解决方案1】:

    我现在看到我从原始帖子复制的示例中的语法错误:

    groupIDs = ("2208833392")

    应该是

    groupIDs = ["2208833392"]

    不过,我仍然遇到错误,如果能就实现我正在尝试做的事情的最佳方式提供任何建议,我将不胜感激。谢谢!

    错误:“需要具有授予 managed_group 权限的管理员或使用已安装应用程序的成员”

    【讨论】:

      猜你喜欢
      • 2018-12-19
      • 1970-01-01
      • 1970-01-01
      • 2019-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多