# LinkedIn Ad Library Scraper (`ivanvs/linkedin-ad-library-scraper`) Actor

Extract details about ads from LinkedIn Ad Library. Scrape ad details like when it was run, ad targeting, advertiser and content of ad. Download ad data in JSON, XML, Excel format.

- **URL**: https://apify.com/ivanvs/linkedin-ad-library-scraper.md
- **Developed by:** [Gen First](https://apify.com/ivanvs) (community)
- **Categories:** Lead generation, Automation, Social media
- **Features:** Limited permissions
- **Stats:** 572 total users, 139 monthly users, 100.0% runs succeeded, 19 bookmarks
- **User rating**: 3.56 out of 5 stars

## Pricing

from $2.40 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## LinkedIn Ad Library Scraper

Scrape Ad Library data from [LinkedIn](https://www.linkedin.com/) easily with LinkedIn Ad Library Scraper.

### About

LinkedIn is a business and employment-focused social media platform that works through websites and mobile apps. It was launched on May 5, 2003 by Reid Hoffman and Eric Ly. Since December 2016, LinkedIn has been a wholly owned subsidiary of Microsoft. The platform is primarily used for professional networking and career development, and allows jobseekers to post their CVs and employers to post jobs. From 2015, most of the company's revenue came from selling access to information about its members to recruiters and sales professionals. LinkedIn has more than 1 billion registered members from over 200 countries and territories.

### Why should you use it?

It provides a structured way to access LinkedIn Ad Library data, enabling easy processing without the need for login credentials or session cookies.

### How to use

In order to use LinkedIn Ad Library Scraper you need to provide number of results that you want to scrape from LinkedIn.

Next go to [Linkedin Ad Library](https://www.linkedin.com/ad-library). Do search that you want. Copy the URL and set it as input paramter for the scraper.

Example of valid URLs for scraping:

- https://www.linkedin.com/ad-library/search?accountOwner=JetBrains
- https://www.linkedin.com/ad-library/search?keyword=jetbrains
- https://www.linkedin.com/ad-library/search?keyword=jetbrains\&countries=FI
- https://www.linkedin.com/ad-library/search?keyword=jetbrains\&countries=FI\&dateOption=current-year
- https://www.linkedin.com/ad-library/detail/349389913

#### Examples

##### Input

```json
{
  "urls": [
    {
      "url": "https://www.linkedin.com/ad-library/search?keyword=jetbrains",
      "method": "GET"
    },
    {
      "url": "https://www.linkedin.com/ad-library/detail/349389913",
      "method": "GET"
    }
  ],
  "maxResults": 100
}
```

##### Output

```json
{
  "url": "https://www.linkedin.com/ad-library/detail/388651983",
  "id": 388651983,
  "format": "SINGLE_IMAGE_AD",
  "creativeType": "SPONSORED_STATUS_UPDATE",
  "period": {
    "start": "2024-04-05",
    "end": "2024-04-15"
  },
  "paidBy": "Paid for by HOOLOOVOO",
  "totalImpression": "10k-50k",
  "impressions": [
    {
      "country": "Sweden",
      "impressions": "100%",
      "estimatedMin": 10000,
      "estimatedMax": 50000,
      "percentage": 100
    }
  ],
  "advertiser": {
    "url": "https://www.linkedin.com/company/101071919",
    "name": "HOOLOOVOO Global",
    "logo": "https://media.licdn.com/dms/image/v2/D4D0BAQGto4ufhsi51A/company-logo_100_100/company-logo_100_100/0/1699612320543/hooloovoo_global_logo?e=2147483647&v=beta&t=MwdLsrA6-pbBDV8LrFRWuA_Iaqtd7JdfwPk-sUBU1gI",
    "headline": null
  },
  "member": null,
  "body": "If you are a sales professional in Sweden, maybe you can help Djordje, our Head of Sales. Read more about him and about the job, here is the link - hooloovoo.se/jobs and check out our website, it's basically our Business Development Strategy published.",
  "hashtags": [],
  "commentaryLinks": [],
  "title": "Djordje needs a Swedish colleague for an adventure in sales",
  "document": null,
  "imageUrls": ["https://media.licdn.com/dms/image/v2/D4D10AQEie13iwpwVxg/image-shrink_1280/image-shrink_1280/0/1712306906591/HLVSales_Li1200x628px2png?e=2147483647&v=beta&t=MCdVnFHC-W6d2zPCVPO05xKsy-AJLwniMrEsV2_9Z1Y"],
  "imageAlt": "Djordje needs a Swedish colleague for an adventure in sales",
  "targetingSettings": [
    {
      "target": "Language",
      "value": "Targeting includes English"
    },
    {
      "target": "Location",
      "value": "Targeting includes Sweden"
    },
    {
      "target": "Job",
      "value": "Inclusion targeting applied"
    }
  ],
  "targetingParameters": [
    { "parameter": "Audience", "targeted": false, "excluded": false },
    { "parameter": "Job", "targeted": true, "excluded": false }
  ],
  "buttons": ["Learn more"]
}
```

### LinkedIn Ad Library Scraper data output

The output from LinkedIn Ad Library Scraper is stored in the dataset. After the run is finished, you can download the dataset in various data formats (JSON, CSV, XML, RSS, HTML Table).

### ❓FAQ

#### Do I need proxies to scrape ads from LinkedIn?

Proxy for this scraper is already preconfigured for optimal performance.

### Support

For more custom/simplify outputs or Bug report please contact the developer (support (at) getmediumdata.com) or report an issue.

# Changelog

This Actor's version history is a separate document: https://apify.com/ivanvs/linkedin-ad-library-scraper/changelog.md

# Actor input Schema

## `maxRecords` (type: `integer`):

Maximum number of records to be scraped

## `urls` (type: `array`):

List of URLs from Linkedin Ad Library page (https://www.linkedin.com/ad-library) that needs to be scraped

## Actor input object example

```json
{
  "maxRecords": 10,
  "urls": [
    {
      "url": "https://www.linkedin.com/ad-library/search?keyword=jetbrains"
    }
  ]
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

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

// Prepare Actor input
const input = {
    "maxRecords": 10,
    "urls": [
        {
            "url": "https://www.linkedin.com/ad-library/search?keyword=jetbrains"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("ivanvs/linkedin-ad-library-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "maxRecords": 10,
    "urls": [{ "url": "https://www.linkedin.com/ad-library/search?keyword=jetbrains" }],
}

# Run the Actor and wait for it to finish
run = client.actor("ivanvs/linkedin-ad-library-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "maxRecords": 10,
  "urls": [
    {
      "url": "https://www.linkedin.com/ad-library/search?keyword=jetbrains"
    }
  ]
}' |
apify call ivanvs/linkedin-ad-library-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,ivanvs/linkedin-ad-library-scraper"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/vOEvl50jL0jIbJPSg/builds/goiu81l7KyniSJ732/openapi.json
