1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "searchTerms": [
12 "running shoes"
13 ],
14 "pageUrlsOrIds": [
15 "https://www.facebook.com/nike"
16 ],
17 "startUrls": [],
18 "countries": [
19 "US"
20 ],
21 "mediaTypes": [],
22 "maxResults": 100,
23 "publisherPlatforms": [],
24 "skipAdIds": [],
25 "maxResultsPerSource": 0,
26 "advertiserNameInclude": [],
27 "advertiserNameExclude": [],
28 "contentLanguages": [],
29 "proxyConfiguration": {
30 "useApifyProxy": true,
31 "apifyProxyGroups": [
32 "RESIDENTIAL"
33 ]
34 }
35};
36
37
38const run = await client.actor("coregent/facebook-ads-library-scraper").call(input);
39
40
41console.log('Results from dataset');
42console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
43const { items } = await client.dataset(run.defaultDatasetId).listItems();
44items.forEach((item) => {
45 console.dir(item);
46});
47
48