Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

5 Commits

Repository files navigation

facebook-scraper-python

PyPIPython versionsLicense

Modern Python alternative to kevinzg/facebook-scraper — the 9.5k-star library that's been abandoned since 2022. Hosted backend means it doesn't break every time Meta changes their HTML.

This repo is a migration landing page + working examples. The actual SDK lives at SocialAPIsHub/socialapis-python and ships as the socialapis-sdk package on PyPI.

pip install socialapis-sdk
fromsocialapisimportFacebookScraperfb=FacebookScraper(api_token="...") # alias of Facebook — keeps your import line greppablepage=fb.get_page_info("EngenSA")
print(page.title, page.followers_count, page.category)
forpostinfb.get_page_posts("EngenSA").get("posts", []):
print(post["text"][:80])

Get a free API token → — 200 calls/month, no credit card


Why this exists

kevinzg/facebook-scraper was the default Python library for scraping Facebook for years. 9.5k+ GitHub stars. It's been abandoned since 2022 — open issues pile up, PRs sit unmerged, and every Meta DOM change breaks it.

If you're here because:

  • facebook-scraper stopped returning data
  • You searched for "facebook-scraper alternative" or "kevinzg fork"
  • Your get_posts() calls started raising TemporarilyBanned or returning empty lists
  • You're tired of patching a library nobody maintains

…this is the modern replacement. Same idea — Facebook public data via Python — but the actual scraping runs on a hosted API (socialapis.io) so you never debug Meta's HTML again.

Side-by-side migration

# BEFORE — kevinzg/facebook-scraper (abandoned)fromfacebook_scraperimportget_page_info, get_postspage=get_page_info("EngenSA")
print(page["name"], page["likes"])
forpostinget_posts("EngenSA", pages=5):
print(post["time"], post["text"][:80])
# AFTER — socialapis (one import line changed)fromsocialapisimportFacebookScraper# alias of Facebookfb=FacebookScraper(api_token="...")
page=fb.get_page_info("EngenSA")
print(page.title, page.likes_count) # typed Pydantic model, IDE autocompleteforpostinfb.get_page_posts("EngenSA").get("posts", []):
print(post.get("time"), post.get("text", "")[:80])

FacebookScraper is an exact alias of socialapis.Facebook — same class, same methods, just a different name so your grep-replace migration stays a one-liner.

Method-by-method mapping

kevinzg/facebook-scrapersocialapis (this SDK)
get_page_info(page)FacebookScraper(api_token=…).get_page_info(page)
get_posts(page, pages=N)FacebookScraper(…).get_page_posts(page)
get_group_info(group)FacebookScraper(…).get_group_details(group)
get_friends(user)(Meta blocked it years ago — even kevinzg deprecated it)
set_proxy(...) / set_user_agent(...)Not needed — we manage the scraping infra
set_cookies(...)Not needed — no Facebook login required

Full working example: examples/migrate.py.

What you get on top of the kevinzg surface

The hosted backend supports more than kevinzg ever did. From the same FacebookScraper instance:

# Group posts + metadatafb.get_group_details("groupslug")
fb.get_group_posts("groupslug")
# Search — pages, people, posts, videos, locationsfb.search_pages("marketing", location_id="103006566409959")
fb.search_posts("nike", recency="last_month")
# Meta Ads Library (full transparency data — creative, spend, impressions)fb.search_ads("fitness", country="US", activeStatus="Active")
fb.get_ad_archive_details(ad_archive_id="...", page_id="...")
# Marketplace (listings, vehicles, rentals)fb.search_marketplace("cars", filter_location_latitude="40.7142", filter_location_longitude="-74.0064")
fb.get_listing_details("123456789")
# Reelsfb.get_page_reels("EngenSA")
# Async — same surface, methods are coroutinesfromsocialapisimportAsyncFacebookScraperasyncwithAsyncFacebookScraper(api_token="…") asfb:
page=awaitfb.get_page_info("EngenSA")

Full method list + Pydantic response types: main SDK README →

Comparison at a glance

kevinzg/facebook-scraper (2018-era)socialapis (2026)
MaintenanceAbandoned 2022Active; 7M+ calls/month in prod
ReliabilityBreaks on every Meta HTML changeHosted backend; we absorb breakage
Type hintsNoneStrict; Pydantic v2 models
AsyncNoFacebook + AsyncFacebook classes
HTTP clientrequestshttpx
AuthNone (anonymous, often rate-limited)Single x-api-token header, 200 free calls/month
PaginationGenerator with edge-case bugsCursor-based; API decides page size
Error handlingGeneric exceptionsTyped hierarchy (RateLimitError, InsufficientCreditsError, …)
TestsManual against live FBRecorded HTTP fixtures, Python 3.10–3.13
Surface areaPage posts, group posts35+ Facebook endpoints + Instagram + Account

Pricing

TierCalls / monthPrice
Free200$0
Pro1,500$4.99
Ultra30,000$49
Mega120,000$179
EnterpriseCustomContact us

One credit per successful call. Failed calls (4xx caused by bad input) don't consume credits.

Other resources

License

MIT — see LICENSE.

The socialapis package this repo points at is also MIT-licensed. Both are open source; the hosted scraping API is the commercial layer.

About

Modern Python alternative to kevinzg/facebook-scraper — no OAuth, doesn't break on every Meta change. Powered by socialapis.io.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors