How to scrape FB group data and store in Google Sheets

# Import the necessary libraries
import facebook
import gspread
from oauth2client.service_account import ServiceAccountCredentials

# Set up the Facebook API client
fb_access_token = "YOUR_APP_ACCESS_TOKEN"
fb_client = facebook.GraphAPI(access_token=fb_access_token, version="3.1")

# Set up the Google Sheets API client
scope = ["https://spreadsheets.google.com/feeds", "https://www.googleapis.com/auth/drive"]
creds = ServiceAccountCredentials.from_json_keyfile_name("client_secret.json", scope)
gs_client = gspread.authorize(creds)

# Open the Google Sheets spreadsheet
spreadsheet = gs_client.open("Facebook Group Posts and Comments")

.... continued .....

Only people mentioned by @4dBender in this post can reply

# Get the latest posts and comments from the Facebook group
fb_posts = fb_client.get_object(id="GROUP_ID/feed")
fb_comments = fb_client.get_object(id="GROUP_ID/comments")

# Add the posts and comments data to the Google Sheets spreadsheet
worksheet = spreadsheet.add_worksheet(title="Facebook Posts and Comments", rows=len(fb_posts["data"]), cols=2)
worksheet.update_cell(1, 1, "Post")
worksheet.update_cell(1, 2, "Comments")
for i, post in enumerate(fb_posts["data"]):
worksheet.update_cell(i + 2, 1, post["message"])
worksheet.update_cell(i + 2, 2, fb_comments["data"][i]["message"])