Scraping Central is reader-supported. When you buy through links on our site, we may earn an affiliate commission.

Guide

How to Scrape Facebook Public Data

Learn how to collect public Facebook data including pages, posts, groups, and marketplace listings. Covers ethical approaches and tools.

Facebook contains vast amounts of public data useful for social media analysis, market research, and brand monitoring. Here is what you can scrape and how.

What Public Data Is Available?

  • Public pages, Posts, follower counts, about info
  • Public groups, Discussions, member counts
  • Marketplace listings, Products, prices, locations
  • Events, Public event details and attendance
  • Business pages, Reviews, hours, contact info

Important: Privacy and Legal Considerations

Facebook actively discourages scraping and has sued companies for it. Only scrape publicly available data, never personal profiles or private groups, and use the data responsibly.

Method 1: Facebook Graph API

The official Graph API is the safest approach but has limited access since 2018.

import requests

access_token = "YOUR_ACCESS_TOKEN"
page_id = "META"
url = f"https://graph.facebook.com/v19.0/{page_id}/posts?access_token={access_token}"

resp = requests.get(url)
posts = resp.json().get("data", [])
for post in posts:
    print(post.get("message", ""), post.get("created_time"))

Limitation: Most endpoints now require app review and specific permissions.

Method 2: Web Scraping with ScraperAPI

For data not available via the API, scrape public Facebook pages with ScraperAPI.

import requests

API_KEY = "YOUR_SCRAPERAPI_KEY"
url = "https://www.facebook.com/Meta/"

resp = requests.get(
    f"http://api.scraperapi.com?api_key={API_KEY}&url={url}&render=true"
)

Facebook is heavily JavaScript-dependent, so rendering is mandatory.

Method 3: CrowdTangle (For Researchers)

Meta's CrowdTangle tool provides access to public social media data for academic researchers and journalists.

Marketplace Scraping

Facebook Marketplace is a growing target for price analysis and deal finding.

# Marketplace requires login and is very difficult to scrape
# Consider using ScrapingAnt with residential proxies
API_KEY = "YOUR_SCRAPINGANT_KEY"

ScrapingAnt with residential proxies works best for Marketplace data since it requires authenticated sessions.

Best Practices

  1. Prefer the Graph API when possible, it is the sanctioned approach
  2. Only scrape public data, Never attempt to access private profiles
  3. Use residential proxies, Facebook blocks datacenter IPs aggressively
  4. Enable JavaScript rendering, Facebook is a single-page application
  5. Rate limit strictly, Facebook monitors request patterns closely
  6. Consult legal counsel, If scraping for commercial use