Skip to content

Help with scraping comments and comment reactions and exporting CSV #811

Answered by neon-ninja
sk1pd1v1d3d asked this question in Q&A
Discussion options

You must be logged in to vote

Here's one way of solving this:

from pprint import pprint
from facebook_scraper import *
import logging
import os
import json
import pandas as pd
from tqdm import tqdm
import time

post_ids = ["pfbid0BwGx3KRtMZtRCb9Aj5vVwugs8jXTcX4QT4hc6UGrfg61DJzFo7mVFTJZReGwWeZZl"]
cookies = "cookies.txt"
set_cookies("cookies.txt")

options = {"comments": 500, "progress": True, "comment_reactors": True}

def format_comment(c):
    obj = {
        "comment_id": c["comment_id"],
        "comment_text": c["comment_text"],
        "comment_reaction_count": c["comment_reaction_count"] or 0,
        "reply_count": len(c["replies"]) if "replies" in c else 0,
        "comment_time": c["comment_time"]
    }
    if 

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sk1pd1v1d3d
Comment options

Answer selected by neon-ninja
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants