whatisgithub

What is facebook-ad-library-scraper?

kyamasam/facebook-ad-library-scraper — explained in plain English

Analysis updated 2026-05-18

1PythonAudience · developerComplexity · 3/5Setup · moderate

In one sentence

A Python tool that scrapes Facebook's public Ad Library search results into JSON and CSV files.

Mindmap

mindmap
  root((facebook-ad-library-scraper))
    What it does
      Builds Ad Library URLs
      Scrolls and scrapes with Chrome
      Parses ad cards
      Exports JSON and CSV
    Tech stack
      Python
      Selenium
      undetected-chromedriver
    Use cases
      Competitor ad research
      Market and ad trend tracking
      Re-parsing saved HTML snapshots
    Audience
      Developers
      Marketers
      Researchers

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Pull ads for a keyword and country into a CSV for competitor or market research.

USE CASE 2

Save HTML snapshots while scraping so ads can be reparsed later without a browser.

USE CASE 3

Build a custom research pipeline using the Python API's build_url, scrape, and parse functions.

What is it built with?

PythonSeleniumundetected-chromedriver

How does it compare?

kyamasam/facebook-ad-library-scrapera-bissell/unleash-liteabhiinnovates/whatsapp-hr-assistant
Stars111
LanguagePythonPythonPython
Setup difficultymoderatehardhard
Complexity3/54/53/5
Audiencedeveloperresearcherdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

Requires Google Chrome installed locally, parsing may break if Facebook changes its page markup.

So what is it?

facebook-ad-library-scraper is a Python tool that automates pulling ad data out of Facebook's public Ad Library search results. Instead of manually browsing and copying information, you give it a search term and a country, and it builds the right Facebook Ad Library URL, opens it in a real Chrome browser using undetected-chromedriver, and scrolls down to load more results the way a person would. As it scrolls, the tool can save snapshots of the raw HTML pages to disk, which is useful if you want to reparse the data later without opening a browser again. It then reads through the ad cards on the page and pulls out details for each one: the advertiser page name and URL, the ad body text, any images, the call to action button and headline, the destination link the ad points to, and whether the ad shows a WhatsApp contact option. Duplicate ads are automatically removed before the results are saved. Results can be exported as a JSON file, a CSV file, or both, along with the saved HTML snapshots in their own folder. The project is available both as a command line tool, where you pass search filters like query, country, active status, media type, and date range as flags, and as a Python library, where functions like build_url, scrape, parse_ads, and parse_from_dir let you build the same workflow into your own scripts. Setup requires Python and Google Chrome installed locally, and the package will usually detect the right Chrome driver version automatically. Because the scraper depends on reading Facebook page structure directly, the README notes that its parsing logic may need updates if Facebook changes how its Ad Library pages are built.

Copy-paste prompts

Prompt 1
Show me how to scrape Facebook Ad Library results for a keyword and country using this CLI.
Prompt 2
Write a Python script using this library's ScraperConfig to scrape ads and save both JSON and CSV output.
Prompt 3
Explain what fields this scraper extracts from each Facebook ad card.
Prompt 4
Help me reparse saved HTML snapshots from this scraper without opening a browser again.

Frequently asked questions

What is facebook-ad-library-scraper?

A Python tool that scrapes Facebook's public Ad Library search results into JSON and CSV files.

What language is facebook-ad-library-scraper written in?

Mainly Python. The stack also includes Python, Selenium, undetected-chromedriver.

How hard is facebook-ad-library-scraper to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is facebook-ad-library-scraper for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.