<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: STU</title>
    <description>The latest articles on DEV Community by STU (@stumadethat).</description>
    <link>https://dev.to/stumadethat</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4252451%2F9fcdfb2f-1cce-468e-bdb6-55c8f0bd8cf3.png</url>
      <title>DEV Community: STU</title>
      <link>https://dev.to/stumadethat</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/stumadethat"/>
    <language>en</language>
    <item>
      <title>How to Scrape the Facebook Ad Library in 2026 (Without the Official API)</title>
      <dc:creator>STU</dc:creator>
      <pubDate>Wed, 18 Nov 2026 18:33:06 +0000</pubDate>
      <link>https://dev.to/stumadethat/how-to-scrape-the-facebook-ad-library-in-2026-without-the-official-api-1i8p</link>
      <guid>https://dev.to/stumadethat/how-to-scrape-the-facebook-ad-library-in-2026-without-the-official-api-1i8p</guid>
      <description>&lt;p&gt;If you run ads, sell online or work at an agency, the &lt;a href="https://www.facebook.com/ads/library/" rel="noopener noreferrer"&gt;Meta Ad Library&lt;/a&gt; is the best free competitive intelligence source there is. Every active Facebook and Instagram ad of every brand is in it, with the creative, the copy and the date it started.&lt;/p&gt;

&lt;p&gt;The problem is getting the data &lt;strong&gt;out&lt;/strong&gt;. There is no export button, the page scrolls forever, and the official API won't return most commercial ads.&lt;/p&gt;

&lt;p&gt;This post covers what the library and its API actually give you, the manual workflow, what I learned building a scraper for it, and how to get a clean dataset plus daily "new ads" alerts in a few minutes.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Disclosure: I built the &lt;a href="https://apify.com/stumadethat/meta-ads-library-monitor" rel="noopener noreferrer"&gt;Meta Ads Library Scraper &amp;amp; Competitor Ad Monitor&lt;/a&gt; Actor on Apify that I use below. Everything else in this post works without it.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  What the Meta Ad Library shows (and what it doesn't)
&lt;/h2&gt;

&lt;p&gt;On the website you can search any brand or keyword, in any country, and see:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;every &lt;strong&gt;active&lt;/strong&gt; ad of a Page: image, video or carousel, ad copy, headline, call to action;&lt;/li&gt;
&lt;li&gt;the &lt;strong&gt;start date&lt;/strong&gt; of each ad and the platforms it runs on (Facebook, Instagram, Messenger, Audience Network, Threads);&lt;/li&gt;
&lt;li&gt;how many ads share the same creative;&lt;/li&gt;
&lt;li&gt;for ads about social issues, elections or politics, and for ads delivered in the EU, extra transparency data such as reach, spend ranges and targeted countries.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What about the official Ad Library API?
&lt;/h3&gt;

&lt;p&gt;Meta does have an &lt;a href="https://transparency.meta.com/researchtools/ad-library-tools/" rel="noopener noreferrer"&gt;Ad Library API&lt;/a&gt;, but read the scope carefully. Meta describes it as covering &lt;strong&gt;ads about social issues, elections or politics, plus ads delivered to the EU and associated territories&lt;/strong&gt;. To use it you need a developer account, and you have to confirm your identity and location.&lt;/p&gt;

&lt;p&gt;In practice, if your competitor is a US e-commerce brand running normal product ads in the US, the API will not return them. The website will. That gap is why most marketers end up scraping the website.&lt;/p&gt;

&lt;h2&gt;
  
  
  The manual way
&lt;/h2&gt;

&lt;p&gt;For a one-off look at one brand, the website is enough:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open facebook.com/ads/library.&lt;/li&gt;
&lt;li&gt;Choose the &lt;strong&gt;country&lt;/strong&gt; and the &lt;strong&gt;"All ads"&lt;/strong&gt; category.&lt;/li&gt;
&lt;li&gt;Type the brand name and select its Page in the suggestions. This fills &lt;code&gt;view_all_page_id&lt;/code&gt; in the URL, so you only see that advertiser.&lt;/li&gt;
&lt;li&gt;Filter by active status, platform or media type, then scroll.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It breaks down quickly when you need to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;compare&lt;/strong&gt; 5 or 10 competitors;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;sort&lt;/strong&gt; ads by how long they've been running (the long runners are usually the winners);&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;share&lt;/strong&gt; the result with a client or your team;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;know what changed&lt;/strong&gt; since last week;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;keep&lt;/strong&gt; the creatives. Image and video links are signed and expire.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  If you want to build a scraper yourself
&lt;/h2&gt;

&lt;p&gt;Here's what I ran into, so you can skip a few days of trial and error:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;You need a real browser.&lt;/strong&gt; The first batch of ads is server-rendered as JSON inside &lt;code&gt;&amp;lt;script type="application/json"&amp;gt;&lt;/code&gt; tags. More ads load through GraphQL requests as you scroll. Walking that JSON for objects that have an &lt;code&gt;ad_archive_id&lt;/code&gt; and a &lt;code&gt;snapshot&lt;/code&gt; gives you clean ads.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Datacenter IPs get nothing.&lt;/strong&gt; In my tests, the same search from a cloud datacenter IP returned zero ads. Residential IPs work.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The page is heavy.&lt;/strong&gt; Meta preloads videos and images as you scroll. Blocking requests to the &lt;code&gt;fbcdn.net&lt;/code&gt; media hosts took a run from about 48 MB of traffic to about 12 MB. That matters a lot when you pay for residential bandwidth.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keyword search is fuzzy.&lt;/strong&gt; "decathlon" also returns other Pages that use the word. Use the Page ID to follow exactly one advertiser.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you'd rather not maintain that, here is the hosted version.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step by step with the Apify Actor
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Run it from the Console (no code)
&lt;/h3&gt;

&lt;p&gt;Open the &lt;a href="https://apify.com/stumadethat/meta-ads-library-monitor" rel="noopener noreferrer"&gt;Actor page&lt;/a&gt; and click &lt;strong&gt;Try for free&lt;/strong&gt;. The free Apify plan includes monthly credits, which is enough for a few thousand ads.&lt;/p&gt;

&lt;p&gt;Fill in the input. All fields are optional except one search term or Page ID:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"searchTerms"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"decathlon"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"pageIds"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"122695097770591"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"country"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"FR"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"activeStatus"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"ACTIVE"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"mediaType"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"ALL"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"maxAdsPerSearch"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;searchTerms&lt;/code&gt;: brand names or keywords. Put a term in double quotes for an exact phrase.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;pageIds&lt;/code&gt;: a numeric Page ID or an Ad Library URL containing &lt;code&gt;view_all_page_id=…&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;country&lt;/code&gt;: an ISO code (&lt;code&gt;US&lt;/code&gt;, &lt;code&gt;GB&lt;/code&gt;, &lt;code&gt;DE&lt;/code&gt;…) or &lt;code&gt;ALL&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;activeStatus&lt;/code&gt;: &lt;code&gt;ACTIVE&lt;/code&gt;, &lt;code&gt;INACTIVE&lt;/code&gt; or &lt;code&gt;ALL&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;mediaType&lt;/code&gt;: &lt;code&gt;ALL&lt;/code&gt;, &lt;code&gt;IMAGE&lt;/code&gt;, &lt;code&gt;VIDEO&lt;/code&gt; or &lt;code&gt;MEME&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Click &lt;strong&gt;Start&lt;/strong&gt;. In my tests a 100-ad search finishes in under a minute.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. What you get
&lt;/h3&gt;

&lt;p&gt;Each ad is one flat JSON row. Here is a real one (image URLs shortened):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"adId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"1749363949758525"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"pageName"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Decathlon France"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"pageId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"122695097770591"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"pageUrl"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://www.facebook.com/Decathlon.France/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"pageLikes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1075826&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"pageCategories"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Sporting Goods"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"isActive"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"firstShown"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2026-06-05"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"lastShown"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2026-11-18"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"daysRunning"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;167&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"platforms"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"FACEBOOK"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"INSTAGRAM"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"MESSENGER"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"THREADS"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"displayFormat"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"DPA"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"isDynamicProductAd"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"bodyText"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Retournez sur le terrain avec Decathlon ! 🏂 …"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"{{product.name}}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"caption"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"decathlon.fr"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"ctaText"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Shop now"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"landingUrl"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"http://www.decathlon.fr/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"imageUrls"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"https://scontent…fbcdn.net/…"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"cardsCount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"reachEstimate"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"spend"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"targetedCountries"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"adLibraryUrl"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://www.facebook.com/ads/library/?id=1749363949758525"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"searchTerm"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"decathlon"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"country"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"FR"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A few fields worth knowing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;daysRunning&lt;/code&gt; is the number to sort by. An ad that has been live for 167 days is almost certainly profitable.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;isDynamicProductAd&lt;/code&gt; flags catalog ads, whose headline is a template like &lt;code&gt;{{product.name}}&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;reachEstimate&lt;/code&gt;, &lt;code&gt;spend&lt;/code&gt; and &lt;code&gt;targetedCountries&lt;/code&gt; are only filled when Meta publishes them: EU-delivered ads, and political or issue ads.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The run also saves two files in its key-value store:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;SUMMARY&lt;/code&gt;&lt;/strong&gt; (JSON), one entry per advertiser: ads collected, active ads, new ads in the last 7 and 30 days, longest-running ad, platforms, formats and top landing domains.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;REPORT&lt;/code&gt;&lt;/strong&gt; (HTML), a shareable page with the same summary and the ads. It's handy to send to a client as is.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Call it from Python
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip install apify-client
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;decimal&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Decimal&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;apify_client&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;ApifyClient&lt;/span&gt;

&lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ApifyClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"YOUR_APIFY_TOKEN"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;run&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;actor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"stumadethat/meta-ads-library-monitor"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;run_input&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"searchTerms"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"decathlon"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"intersport"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"country"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"FR"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"activeStatus"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"ACTIVE"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"maxAdsPerSearch"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;max_total_charge_usd&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;Decimal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"1.00"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;# hard cap for this run&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;ads&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dataset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;default_dataset_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;list_items&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;

&lt;span class="c1"&gt;# The ads that have been running longest are usually the winners&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;ad&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ads&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"daysRunning"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reverse&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ad&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"daysRunning"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ad&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"pageName"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ad&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"ctaText"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ad&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"landingUrl"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Per-advertiser summary&lt;/span&gt;
&lt;span class="n"&gt;summary&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;key_value_store&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;default_key_value_store_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_record&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"SUMMARY"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;summary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"advertiserName"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"adsCollected"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"ads,"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"newAdsLast7Days"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"new this week"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is written for &lt;code&gt;apify-client&lt;/code&gt; 3.x. On 2.x, &lt;code&gt;run&lt;/code&gt; is a dict, so use &lt;code&gt;run["defaultDatasetId"]&lt;/code&gt; and &lt;code&gt;run["defaultKeyValueStoreId"]&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Turn it into a competitor monitor
&lt;/h3&gt;

&lt;p&gt;This is the part I actually built the Actor for. Set:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"pageIds"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"122695097770591"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"country"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"FR"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"onlyNewAds"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first run stores a baseline of the ads it has seen. Every later run with the same search (same terms, country, status and media type) returns &lt;strong&gt;only ads it has never seen before&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;To run it every morning:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;On the Actor page, save your input as a &lt;strong&gt;Task&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Go to &lt;strong&gt;Schedules → Create new&lt;/strong&gt;, pick a time (for example daily at 08:00) and add the task.&lt;/li&gt;
&lt;li&gt;Optionally, add an integration on the task (email, Slack or a webhook) to be notified when a run finishes.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you want to start from scratch later, change &lt;code&gt;monitorStoreName&lt;/code&gt;, and the history resets.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Export to CSV, Excel or Google Sheets
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;From the Console:&lt;/strong&gt; open the run's &lt;strong&gt;Storage&lt;/strong&gt; tab and export the dataset as CSV, Excel or JSON.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;From Python:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;csv_bytes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dataset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;default_dataset_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_items_as_bytes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item_format&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"csv"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"meta_ads.csv"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"wb"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;csv_bytes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Into Google Sheets automatically:&lt;/strong&gt; Make, Zapier and n8n all have Apify modules. Trigger on "run succeeded" from your schedule, then append the dataset rows to a sheet.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Pricing and limits
&lt;/h2&gt;

&lt;p&gt;The Actor is pay-per-result:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Event&lt;/th&gt;
&lt;th&gt;Price&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Ad&lt;/td&gt;
&lt;td&gt;$0.80 per 1,000 ads&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Summary + HTML report&lt;/td&gt;
&lt;td&gt;$0.01 per search&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Example: 500 ads from 3 searches cost $0.43. You can set a maximum cost per run, and the Actor stops cleanly when it reaches it.&lt;/p&gt;

&lt;p&gt;Honest limits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It uses &lt;strong&gt;residential proxies by default&lt;/strong&gt;, because Meta returns nothing to datacenter IPs. Don't switch that off.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Image and video links expire.&lt;/strong&gt; They are signed by Meta, so download what you want to keep.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reach and spend data&lt;/strong&gt; only exist for the ads Meta publishes them for (EU-delivered ads, and political or issue ads).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keyword searches are fuzzy.&lt;/strong&gt; Use a Page ID for exact tracking.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Is it legal?
&lt;/h2&gt;

&lt;p&gt;The Actor only reads ads that Meta publishes in its &lt;strong&gt;public&lt;/strong&gt; Ad Library, without logging in and without any account. That data exists precisely so that anyone can see who advertises what. Still, check Meta's terms and your local laws for your use case, and don't use the data to target individuals.&lt;/p&gt;

&lt;h2&gt;
  
  
  The same workflow for Google and TikTok
&lt;/h2&gt;

&lt;p&gt;Competitors rarely advertise on one network only. I built two sister Actors with the same input style, the same &lt;code&gt;daysRunning&lt;/code&gt;, the same monitoring mode and the same HTML report:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://apify.com/stumadethat/google-ads-transparency-monitor" rel="noopener noreferrer"&gt;Google Ads Transparency Scraper &amp;amp; Competitor Ad Monitor&lt;/a&gt;: Search, YouTube, Shopping, Maps and Play ads of any advertiser, in any country.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://apify.com/stumadethat/tiktok-ads-library-monitor" rel="noopener noreferrer"&gt;TikTok Ads Library Scraper &amp;amp; Competitor Ad Monitor&lt;/a&gt;: TikTok ads shown in Europe, with targeting, payer and landing page.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If something is missing for your use case, open an issue on the Actor page. I read them.&lt;/p&gt;

</description>
      <category>python</category>
      <category>webscraping</category>
      <category>marketing</category>
      <category>api</category>
    </item>
  </channel>
</rss>
