user6136083
user6136083

Reputation: 1

facebook_scraper.get_posts not returning any posts

I'm trying to use https://github.com/kevinzg/facebook-scraper to scrape comments from public Facebook pages. I'm not getting any posts returned, even when I use the examples in the docs.

Here's an example from the docs that returns nothing at all:

print("")
print("")

# example from docs
from facebook_scraper import get_posts

for post in get_posts('nintendo', pages=5):
    print(post['text'][:50])

print("")
print("")

Here's another example from the docs that returns a single item that does not include the comments:

#example from the docs
POST_ID = "pfbid02NsuAiBU9o1ouwBrw1vYAQ7khcVXvz8F8zMvkVat9UJ6uiwdgojgddQRLpXcVBqYbl"

# number of comments to download -- set this to True to download all comments
MAX_COMMENTS = 10

# get the post (this gives a generator)
gen = fs.get_posts(
    post_urls=[POST_ID],
    options={"comments": MAX_COMMENTS, "progress": True}
)

# I added this to check the size 
gen_copy, gen = itertools.tee(gen)  # Create a copy
length = sum(1 for _ in gen_copy)  # Count items without exhausting the original

print(length)  
print(gen)

# take 1st element of the generator which is the post we requested
post = next(gen)

print("post is ", post)

That second example returns this:

1

<itertools._tee object at 0x000001608C49AB00>

post is  {'original_request_url': 'pfbid02NsuAiBU9o1ouwBrw1vYAQ7khcVXvz8F8zMvkVat9UJ6uiwdgojgddQRLpXcVBqYbl', 'post_url': 'https://m.facebook.com/pfbid02NsuAiBU9o1ouwBrw1vYAQ7khcVXvz8F8zMvkVat9UJ6uiwdgojgddQRLpXcVBqYbl'}

I expect the generator returned by get_posts to be made up of posts that are dicts with keys that include "comments" and "comments_full" that I can then use.

Upvotes: 0

Views: 27

Answers (0)

Related Questions