Facebook Ad Library Scraper (Playwright) avatar

Facebook Ad Library Scraper (Playwright)

Pricing

from $10.00 / 1,000 results

Go to Apify Store
Facebook Ad Library Scraper (Playwright)

Facebook Ad Library Scraper (Playwright)

Scrape ads from Meta Ad Library using Playwright. Intercepts GraphQL responses for structured data extraction. No API key or Facebook account required.

Pricing

from $10.00 / 1,000 results

Rating

0.0

(0)

Developer

Admo Solutions

Admo Solutions

Maintained by Community

Actor stats

0

Bookmarked

1

Total users

0

Monthly active users

17 hours ago

Last modified

Categories

Share

Facebook Ad Library Scraper

Scrape ads from Meta's public Ad Library using Playwright. Supports two modes: keyword search and Facebook page scraping. Extracts comprehensive ad data including page IDs, URLs, CTA details, platforms, media assets, and carousel cards — no API key or Facebook account required.

Why use this Actor?

  • Two scraping modes — Search by keyword OR scrape ads from Facebook page URLs
  • Bulk cursor pagination — Fetch hundreds of ads (500+) via Facebook's Relay GraphQL pagination instead of slow scrolling
  • Date filtering — Filter by ad start date (startDateMin / startDateMax), applied at the URL level and as a post-scrape filter
  • Page enrichment (optional) — Add page likes, followers, phone, email, website, address, category and rating to every ad
  • No API key required — Uses the public Ad Library website
  • Rich media fields — imageUrls, videoUrls, displayFormat, caption, profileImageUrl
  • Deduplication — Automatically deduplicates by ad archive ID
  • Structured output — Clean JSON dataset with full ad metadata
  • Self-contained — No external Actor dependencies

How to use

Mode 1: Search by keyword

  1. Enter a search term (e.g., "skincare", "fitness coaching", "SaaS")
  2. Optionally set a country code (e.g., "US", "IN", "GB")
  3. Run the Actor

Mode 2: Scrape ads from Facebook pages

  1. Add Facebook page URLs to the "Facebook Page URLs" field
  2. Optionally set a country code
  3. Run the Actor

Supported URL formats:

  • https://www.facebook.com/ZapierApp
  • https://www.facebook.com/profile.php?id=123456
  • facebook.com/YourPage

Input

FieldDescriptionDefault
Search TermsKeywords to search in Ad Library (search mode)"skincare"
Page URLsFacebook page URLs to scrape ads from (page mode)[]
Country CodeISO-2 letter country code, empty = worldwide"US"
Ad TypeFilter by ad category"ALL"
Active StatusFilter by active/inactive"ACTIVE"
Start Date MinOnly ads started on/after this date (YYYY-MM-DD)""
Start Date MaxOnly ads started on/before this date (YYYY-MM-DD)""
Enrich PagesVisit each page to add likes/phone/etc. fieldsfalse
Max ItemsMaximum ads to extract100
Max ScrollsScroll iterations (used as fallback)20
Scroll DelayDelay between scrolls (ms)2000
Proxy ConfigurationApify Proxy — leave off for small runsoff

Output

Each ad contains:

FieldDescription
adArchiveIdUnique ad identifier
pageId / pageName / pageUrlAdvertiser page info
body / title / captionAd text content
linkUrl / ctaText / ctaTypeCTA destination and button
startDate / endDate / isActiveFlight dates (YYYY-MM-DD)
platformsWhere the ad runs (Facebook, Instagram, ...)
mediaType / displayFormatimage, video, carousel, text
imageUrls / videoUrls / profileImageUrlMedia asset URLs
beneficiaryName / payerNameFunding transparency fields
sourceWhich input source produced this ad
snapshotRaw extra metadata (categories, likes, cards)

With Enrich Pages enabled, each ad additionally gets: pageLikes, pageFollowers, pagePhone, pageEmail, pageWebsite, pageAddress, pageCategory, pageCategories, isVerified, pageRating, pageRatingCount.

How it works

  1. Navigation — Loads the Ad Library search/page results with waitUntil: commit (Facebook's multi-MB payload hangs domcontentloaded over proxies)
  2. Relay cache extraction — Parses all embedded ad_library_main.search_results_connection.edges JSON blobs from the page source, deduped by ad archive ID
  3. Bulk cursor pagination — Harvests the end_cursor from page HTML, sniffs the live doc_id from Facebook's JS bundles, then walks the Relay AdLibrarySearchPaginationQuery endpoint with the session's cookies — hundreds of ads in seconds instead of scrolls
  4. Scroll fallback — If pagination isn't available (exhausted cursor, no doc_id), scrolls the results container with stale-round detection
  5. Date filter — Post-scrape inclusive filter on startDate
  6. Deduplication — By ad archive ID across all sources

Tips

  • Small runs (≤ ~30 ads): no proxy needed — keep Proxy Configuration off
  • Bulk runs (500+): enable Apify Proxy with the RESIDENTIAL group and country US — Facebook rate-limits datacenter IPs (error 1675004)
  • Higher maxScrolls only matters when pagination falls back to scrolling
  • Start with maxItems: 100 to test, then increase as needed

Cost Estimation

  • 100 ads: ~$0.05-0.15 compute
  • 500 ads (bulk pagination): ~$0.15-0.40 compute
  • Proxy costs depend on your plan

Known Limitations

  • Facebook may block datacenter IPs — bulk pagination needs a residential proxy
  • Ad Library page structure changes may require updates to the Relay cache parser
  • Enrich Pages adds ~1-3s per unique page (browser visits)

Disclaimer

Our Actors are ethical and do not extract any private user data. They only extract what has been chosen to share publicly on the Meta Ad Library. We therefore believe that our Actors, when used for ethical purposes by Apify users, are safe. However, you should be aware that your results could contain personal data. Personal data is protected by the GDPR in the European Union and by other regulations around the world. You should not scrape personal data unless you have a legitimate reason to do so. If you're unsure whether your reason is legitimate, consult your lawyers.

Support

  • Having trouble? Open an Issue on the Actor page.
  • For programmatic access, see the API tab.