3

I want to scrape comments from a public facebook page (news network) through the facebook graph api. However it says i need to create a app to do this.

After a bit of research I found out that facebook prohibits web scraping since the cambridge analytica scandal.

Is there still a legal way to scrape data from facebook? Does somebody here have experience he/she can share? Thank you in advance.

gython
  • 865
  • 4
  • 18
  • I'm guessing that violates their terms of service. Since you must log in to see their web site, I'm guessing your account would get suspended. – Trenton McKinney Jun 14 '20 at 19:40

2 Answers2

4

I dont know about the legality of scraping facebook, but you can use a library called facebook_scraper

for instance:

from facebook_scraper import get_posts

for post in get_posts(name_of_your_public_group, pages=10):
    print(post['text'],'\n')

Note: working only for public pages

YosDos
  • 391
  • 3
  • 13
3

It is possible, but you have to create an App and apply for Page Public Content Access: https://developers.facebook.com/docs/apps/features-reference#reference-PAGES_ACCESS

...after that, you can get the feed of a public Page with the /page-id/feed endpoint, with an App Access Token.

andyrandy
  • 72,880
  • 8
  • 113
  • 130