Climb the Facebook Creative Gallery (with tools attached)

Click to read the original text for free. Small breaking site configuration is low, only open for two days to the visiting officer experience. If there is a custom needs can be private chat Oh

The other day, a classmate asked me if I could grab the ad material in my Facebook ad library and automatically send new material for the specified product every day as needed.

Facebook's ad library theoretically lists all the creatives that appear on Facebook, which are usually viewed directly on its page. But if you're focusing on a lot of products at the same time, it does take a lot of time to see them one by one.

So now that there's a need, let's do it. In the lower left corner of the ad gallery page there is a link to the Ad Library API, so simple, the interface is so slyly given out? I feel like it's far from that simple...

It's not possible, try it again. Open the Facebook Graph API Explorer and follow the instructions in the documentation, find a fan page ID for your product and fill in the parameters:

Sure enough, the tip is:

For access to the API you need to be authorized and logged into Facebook.To begin authorization, you can visit facebook.com/ID.


The account needs to be verified. Visit ingress with this link address and jump to the following page:

(I've tried to verify, so there's a record below)

You're going to have to go through an identity review to run political ads on Facebook. Feel not quite right ah, call a query advertising interface only, I do not spend money to put ah!

People under the eaves have to bow, audit on the audit bar, click to start verification:

No China!? I'm just going to adjust the interface how it's so hard!

All right, you can only pick up your daughter-in-law's Facebook account and Taiwan passport and submit it for review. After 1 day, the audit passed. Let's move on.

(There should have been a screenshot here)

WTF, and it was reported wrong again. Should have put a screenshot, but too lazy to change account again try, not cut. In short, two days to find out through this interface can only query political ads, no wonder to pass the previous audit.

So what do you put so many options on the parameters of this interface? Clearly, only political ads can be chosen. So, Facebook's opening up of this interface is only under political and public pressure, and ordinary advertisers don't want to easily get other advertisers' material through it.

In this case, there is no way to implement the opening requirements by calling the interface. I'm not going to crack Facebook's encryption algorithm, so it's simple to make a rude offer for Puppeteer.


Puppeteer

Puppeteer is a tool introduced by the Google Chrome team that allows us to simulate real-world operations in Chrome browsers by calling APIs. It is widely used for automated testing and web crawlers.


The idea is simple, access

https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=ALL&impression_search_field=has_impressions_lifetime&view_all_page_id=

This link, add the ID of the fan page to the last side of the link, you can see all the ads on the fan page. Facebook uses Ajax to present and load data, so it needs to keep scrolling the page to the bottom to get more data.

(Scroll to the bottom of the page to load more)

Each ad element is similar to this:

We can summarize the ID, time online, title, description, and video/image link for each ad.

Finally, check the designated fan page regularly every day and email yourself the time of yesterday's ad.

Because the project code is lengthy, it is no longer uploaded here.