Scraping the Facebook Ads Library API
Scrape Facebook Ads Library data legally without violating Meta’s Terms of Service using a little-known technique involving web scraping with HAR files with our Facebook Ads scraper.
This can be very useful if you need to Download Videos from the Facebook Ads Library for competitive research or just “borrow” some creative inspiration from the social media platform.
You’ll be able to download the public ad creatives, videos & landing pages for any Facebook advertiser without waiting to be approved for the extremely limited Facebook Ads Library API, which is limited to only political advertising, requires you to manually be approved for an API key and is useless for most Facebook and Instagram advertisers.
This Facebook data can save you thousands of dollars in wasted ad spend by understanding what messages are working for your competitors (if the same ad has been running for a long time, it’s probably working) and see exactly which landing page URLs they are directing traffic to.
1. Browse Facebook Ads
Go to the Facebook Ads Library (or Meta Ads Library) and use the “Search Ads” form to find ads you’re interested in scraping data about. Unlike using the Facebook Ad Library API, you can select from any ad category, not just political ads:
To narrow down your search even more, you can apply filters (look for the button on the upper right part of the page). Review and apply the filters that make sense for you, then the results will reload.
On your web browser (we’ll assume you’re using Google Chrome, but these instructions should be similar for any browser), right click anywhere on the page and hit Inspect
to open up developer tools (this will allow you to record your web traffic with the Facebook Ads data in it). You can then click on the “Network” tab to see your web traffic with the data in it.
Now that developer tools are open, we’re “recording” the raw data that Facebook sends back to our browser that we want to scrape. This is the key reason our approach is totally legal, as we scrape the data from your recording instead of the actual Facebook website.
In order to capture the initial results that were sent, we need to first refresh the page (so Facebook sends the data again while we’re recording). Once you refresh the page, begin to scroll down and you’ll see in your browser’s “Network Tab” Facebook send more and more data we’re recording.
2. Export a HAR File
Once you’re done scrolling, look for a download arrow in your browser’s developer tools (Network Tab) that’s labeled something along the lines of “Export HAR…” Click this and save the HAR file somewhere you can access quickly, like your Desktop:
Now that we have the data inside this large file, the trick is to get the data out of this file. For this, we suggest using our HAR File Web Scraper where you can upload the file here, and the software will parse everything out for you and group together all the different requests with the Facebook Ads data in it:
3. Download Ads Data
You can click the disk icon next to the individual requests and download the raw JSON for each individual request for free. However, if you have a budget then you may want to consider using the “Parse” feature of the HAR File Web Scraper.
If you click the “Parse Group” button on the top of the grouped responses, you’ll see combined results of all the ads you scrolled through. For example, the first collection shows the 193 ads we scrolled through in a single table we can download as a CSV file:
You’ll also see other features of the ads in the extracted data, like Facebook page name & ID, call out extensions & image URLs you can download:
You can explore more collections to get even more data back - like seeing the exact date and time the ad was created (long-running ads are a sign that the ad works). Unfortunately though the raw stats for these ads aren’t included in the response and this data is better suited for helping to understand the creative landscape of the market you’re advertising in.
Downloading Videos
If you want to know how to download video from Facebook Ads library, we’ll walk through an additional collection you can look for in the HAR File Web scraper that will contain links to the image previews and full HD versions of the videos used in ads, so you can download video ads locally for your own analysis & discussion.
Simply look for the collection(s) ending in “Videos” and click the “Download CSV” button. The result will contain references to the parent ads on the right side of the CSV file, this way you not only have a link to download the videos, but also a reference to the parent ad objects and metadata:
Why Scrape Facebook Ads?
If you’re running social media ads on Facebook & Instagram (or an ad agency looking to Find Clients for Your SMMA), a crucial component for success is understanding what ads are working for your competitors and similar advertisers who are reaching your target audience.
This can save you thousands of dollars in wasted ad spend and will also help you understand how to position your messaging to stand out from your competitors ads and the hundreds of other active ads your audience sees.