
Facebook Ads Library Scraper
Pricing
Pay per event

Facebook Ads Library Scraper
This Apify Actor scrapes ads from Facebook's Ad Library based on the provided URL. It will extract ad data, including ad content, page information, and targeting details. It automates the browsing process, handles dynamic content loading, and provides structured data output.
0.0 (0)
Pricing
Pay per event
0
7
6
Last modified
10 days ago
Facebook Ad Library Scraper
This Apify Actor scrapes ads from Facebook's Ad Library based on provided URL. It will extract comprehensive ad data including ad content, page information, and targeting details. It automates the browsing process, handles dynamic content loading, and provides structured data output.
Features
- Complete Ad Extraction: Extracts all ads from Facebook Ad Library pages, not just the first few
- Dynamic Content Loading: Automatically scrolls and loads additional ads through GraphQL responses
- Deduplication: Prevents duplicate ads using persistent storage across runs
- Comprehensive Data: Extracts ad content, page details, timestamps, and targeting information
- Flexible Input: Configure the scraper using Facebook Ad Library URLs or page URLs
- Structured Output: Provides results in clean, machine-readable JSON format
Input Schema
The actor is configured using a JSON object with the following properties.
URLs (Required)
You must provide Facebook Ad Library URLs or Facebook page URLs to scrape.
{"startUrls": [{"url": "https://www.facebook.com/ads/library/?active_status=all&ad_type=all&country=ALL&view_all_page_id=123456789","method": "GET"},{"url": "https://www.facebook.com/examplepage/","method": "GET"}]}
Input Parameters
{"startUrls": [{"url": "https://www.facebook.com/ads/library/?active_status=all&ad_type=all&country=ALL&view_all_page_id=123456789","method": "GET"}],"maxScrolls": 10,"waitTime": 5000}
Input Fields
startUrls
(array, required): List of Facebook Ad Library URLs or Facebook page URLs to scrapemaxScrolls
(integer, optional): Maximum number of scroll attempts to load more ads (default: unlimited)waitTime
(integer, optional): Wait time in milliseconds between actions (default: 5000)
Supported URL Types
-
Facebook Ad Library URLs: Direct links from Facebook's Ad Library with search parameters
- Example:
https://www.facebook.com/ads/library/?active_status=all&ad_type=all&country=ALL&view_all_page_id=123456789
- Example:
-
Facebook Page URLs: Direct Facebook page URLs that will be converted to Ad Library searches
- Example:
https://www.facebook.com/examplepage/
- Example:
Output
The actor returns a dataset where each item represents a scraped Facebook ad.
Example Ad Output Item
{"ad_archive_id": "123456789012345","page_id": "987654321098765","snapshot": {"body": {"text": "Discover our latest collection! Limited time offer."},"caption": "shop.example.com","ctaText": "Shop Now","ctaType": "SHOP_NOW","linkUrl": "https://shop.example.com/collection","title": "Summer Collection 2024","images": ["https://scontent.example.com/image1.jpg"],"videos": [],"pageId": "987654321098765","pageName": "Example Store"}}
Output Fields
The actor extracts the following fields for each ad:
- Ad Identification:
ad_archive_id
,page_id
- Ad Content:
snapshot.body.text
,snapshot.title
,snapshot.caption
- Call-to-Action:
snapshot.ctaText
,snapshot.ctaType
,snapshot.linkUrl
- Media:
snapshot.images
,snapshot.videos
- Page Information:
snapshot.pageId
,snapshot.pageName
How It Works
- Page Loading: The scraper loads Facebook Ad Library pages or converts page URLs to Ad Library searches
- Initial Extraction: Extracts ads from initial page scripts containing
ad_library_main
data - Dynamic Loading: Scrolls through the page to trigger GraphQL requests for additional ads
- Deduplication: Uses persistent storage to prevent duplicate ads across runs
- Data Processing: Processes each ad's collated results and snapshot data
- Output: Saves each unique ad as a separate item in the dataset
Why Scrape Facebook Ads?
💪 Competition Intelligence: Analyze competitor advertising strategies and messaging
🕵️ Market Research: Understand industry trends and advertising patterns
📈 Brand Monitoring: Track how brands present themselves across different campaigns
🤳 Creative Analysis: Study ad creative elements and copywriting approaches
📊 Performance Insights: Gather data for advertising strategy optimization
Usage
- Navigate to the Actor page on the Apify platform
- Click "Try actor"
- Enter your input configuration in the JSON editor with Facebook Ad Library URLs or page URLs
- Configure optional parameters like
maxScrolls
andwaitTime
if needed - Click "Start" to run the actor
- Once the run is complete, view and download the results from the "Dataset" tab
Technical Notes
- The scraper handles dynamic content loading through GraphQL responses
- Deduplication is implemented using persistent KeyValue storage
- Each ad is saved as a separate dataset item for easier analysis
- The scraper respects Facebook's rate limits and includes appropriate delays
- Supports both initial page script extraction and dynamic content loading
Legal and Ethical Considerations
This scraper only extracts publicly available advertising data from Facebook's Ad Library. It does not:
- Extract private user information
- Bypass Facebook's intended public access mechanisms
- Violate Facebook's terms of service for public ad data
The Facebook Ad Library is designed for transparency and public access to advertising content. However, you should:
- Respect rate limits and avoid overwhelming Facebook's servers
- Use the data responsibly and in compliance with applicable laws
- Consider Facebook's Terms of Service and robots.txt guidelines
Limitations
- The scraper may not capture ads that are heavily restricted by geographic or demographic targeting
- Some ads may have limited visibility based on Facebook's algorithmic decisions
- Performance may vary based on page size and ad volume
- Dynamic content loading depends on Facebook's current implementation