••• Bender ••• @4dBender
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.googl... "https://www.googleapis.com...
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 .....
03:21 PM - Dec 13, 2022
Only people mentioned by 4dBender in this post can reply
••• Bender ••• @4dBender
13 December, 03:22
In response ••• Bender ••• to his Publication
# 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"])

Notice: Undefined index: tg1tga_access in /home/admin/www/anonup.com/themes/default/apps/timeline/post.phtml on line 396