Small, copy-paste examples for pulling public Facebook data into Python with the five Alfalfa Actors on Apify: events, posts, pages, comments and the Ad Library. No Facebook login, same output fields as the official Apify scrapers, from $0.50 per 1,000 results.
pip install apify-client pandas
export APIFY_TOKEN=... # console.apify.com -> Settings -> Integrations| Script | What it does |
|---|---|
examples/ads_library.py |
ads for a keyword or advertiser page, with EU reach details, to a DataFrame and CSV |
examples/ads_analysis.py |
the analysis marketers actually want: longest-running ads, versions, CTA and landing-domain mix, weekly launches |
examples/events.py |
events by keyword or city with organizer emails |
examples/posts.py |
posts of a page since a date, engagement columns |
examples/pages.py |
page contact details (email, phone, website, address) for a list of page URLs |
examples/comments.py |
all comments and replies of a post as one flat table |
examples/common.py |
one helper: run an Actor and return its dataset as a list of dicts |
Every script is a plain function you can import. Runs are billed per result by Apify; a test with max_items=20
costs about a cent.
Docs for each Actor's input and output: the README on its Store page. Not affiliated with Meta.