FAcebook Ads library src video/images
Hi everyone,
I'm building a scraper using Apify for the Facebook Ads Library. I'm fetching ad data via the Ads Library API, which provides details including an ad_snapshot_url. The issue is that the direct URL for the ad creative (the image or video file) is not included in the API response.
My approach is to open the ad_snapshot_url with Playwright and attempt to extract the <img> or <video> element from the DOM.
However, Facebook detects this and blocks my attempt. The page doesn't load correctly, and the target element is missing from the DOM structure.
What is the most effective way to bypass this block and get the direct URL for the creative? Are there any established best practices for using Playwright in this scenario, or is there an alternative method to get this URL?
Thanks for any advice. @Helper
3 Replies
Browser is not necessary, see https://apify.com/apify/facebook-ads-scraper - by running browser you probably running anti-bot, so solution is to use cheerio or http scraper
Apify
📢 Facebook Ads Scraper · Apify
Scrape Facebook ads from any Facebook page. Download reach estimates, impressions, publisher platforms, ad IDs, and more in Excel, CSV, JSON.
Yes, I saw that cheerio scraper is used there, but when using cheerio scraper, there is a problem with HTML rendering and the given element is then not visible. @Helper
You can take some inspiration from here on how to bypass blocks with browser:
https://docs.apify.com/academy/anti-scraping
https://blog.apify.com/crawl-without-getting-blocked/
also, using RESIDENTIAL proxies might be a good idea, if you are dealing with fb