dfreelon / fb_scrape_public

Scrapes posts and comments from public Facebook pages.
BSD 3-Clause "New" or "Revised" License
106 stars 52 forks source link

Doesn't seem to work for finding post comments? #2

Closed LachieKimber closed 7 years ago

LachieKimber commented 7 years ago

I tried to test your code with a random post from Mark Zuckerberg (public) https://www.facebook.com/zuck/posts/10103695315624661

This is the code I used: comments = scrape_fb("**HIDDEN**","**HIDDEN**","10103695315624661"

The result is:

HTTP Error 400: Bad Request
Skipping ID 10103695315624661 ...
Script completed in 1.4182591438293457 seconds.
>>> 

Please help!

dfreelon commented 7 years ago

OK, I looked into it--technically "zuck" is a user, for which Facebook does not allow the downloading of posts. The API can only be used to download posts or comments from public pages or groups.

LachieKimber commented 7 years ago

I tried the same thing with another public page trying to grab comments by postid. This is the post I tried: https://www.facebook.com/abcnews.au/posts/10156628419339988/ (its definitely a page and public)

I used the same code with the postid being 10156628419339988

And the error is about the same:

HTTP Error 400: Bad Request
Skipping ID 10156596620439988 ...
Script completed in 0.9606900215148926 seconds.
>>> 
dfreelon commented 7 years ago

That's not gonna work. You need to download the posts via the script first, then pull the post IDs from the output and insert them into the program. Post IDs need the user ID prefixed with an underscore. See https://stackoverflow.com/questions/31353591/how-should-we-retrieve-an-individual-post-now-that-post-id-is-deprecated-in-v

Oh and another thing... you have to change the scrape_mode attribute to "comments." So something like this should work:

comments = scrape_fb("app_id","app_secret","6815841748_10154508876046749",scrape_mode="comments")

Best, /DEEN