Actor is under maintenance

This actor may be unreliable while under maintenance. Would you like to try a similar actor instead?

Actor picture

Facebook Pages Scraper

pocesar/facebook-pages-scraper

Facebook scraping tool to crawl and extract data from Facebook Pages. Our fully updated FB scraper downloads posts, likes, comments, reviews, contact details, social media profiles, address, and all public data from Facebook Pages. Download data as JSON, CSV, Excel, XML, and more.

No credit card required

Author's avatarPaulo Cesar
  • Modified
  • Users5,746
  • Runs508,035
Actor picture

Facebook Pages Scraper

To run the code examples, you need to have an Apify account. Replace <YOUR_API_TOKEN> in the code with your API token. For a more detailed explanation, please read about running actors via the API in Apify Docs.

const { ApifyClient } = require('apify-client');

// Initialize the ApifyClient with API token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare actor input
const input = {
    "startUrls": [
        {
            "url": "https://www.facebook.com/apifytech/"
        }
    ],
    "language": "en-US",
    "searchLimit": 10,
    "maxPosts": 3,
    "maxPostComments": 15,
    "maxReviews": 3,
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    },
    "extendOutputFunction": async ({ data, item, customData, Apify }) => {
        return item;
    },
    "extendScraperFunction": async ({ page, LABELS, label, request, username, map, fns, customData, Apify }) => {
        if (label === 'HANDLE') {
            // this is inside the handlePageFunction
        } else if (label === 'SETUP') {
            // before starting the crawler
        } else if (label === 'FINISH') {
            // after finishing the crawler
        }
    },
    "customData": {},
    "maxRequestRetries": 5,
    "maxConcurrency": 20
};

(async () => {
    // Run the actor and wait for it to finish
    const run = await client.actor("pocesar/facebook-pages-scraper").call(input);

    // Fetch and print actor results from the run's dataset (if any)
    console.log('Results from dataset');
    const { items } = await client.dataset(run.defaultDatasetId).listItems();
    items.forEach((item) => {
        console.dir(item);
    });
})();