# Linkedin comment scraper (`curious_coder/linkedin-comment-scraper`) Actor

Scrape comments from any linkedin post with following details: Comment text, Comment author details, Total Likes, Total replies, etc

- **URL**: https://apify.com/curious\_coder/linkedin-comment-scraper.md
- **Developed by:** [Curious Coder](https://apify.com/curious_coder) (community)
- **Categories:** Social media
- **Stats:** 1,095 total users, 6 monthly users, 70.9% runs succeeded, 25 bookmarks
- **User rating**: 2.13 out of 5 stars

## Pricing

$25.00/month + usage

To use this Actor, you pay a monthly rental fee to the developer. The rent is subtracted from your prepaid usage every month after the free trial period.You also pay for the Apify platform usage, which gets cheaper the higher Apify subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#rental-actors

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

### How it works
Scrape comments from any linkedin post by providing link to any linkedin post. It gives you complete comment details: comment text with mentions and other entities info, and author details, etc


Check out other similar scrapers: 

- [Youtube comment scraper](https://apify.com/supreme_coder/youtube-comment-scraper/)
- [Facebook comment scraper](https://apify.com/curious_coder/facebook-comment-scraper)
- [Twitter comment scraper](https://apify.com/curious_coder/twitter-replies-scraper)

### Sample data
Here is the sample output of this actor:

```json
{
	"time": 1673540713770,
	"formattedTime": "2023-01-12T16:25:13.770Z",
	"link": "https://www.linkedin.com/feed/update/urn:li:activity:7019294467031543808?commentUrn=urn%3Ali%3Acomment%3A%28activity%3A7019294467031543808%2C7019338509924597761%29&dashCommentUrn=urn%3Ali%3Afsd_comment%3A%287019338509924597761%2Curn%3Ali%3Aactivity%3A7019294467031543808%29",
	"text": "European Commission FOREST PRODUCTS are missing. ​Johan Falkman​",
	"entities": [
		{
			"start": 0,
			"length": 19,
			"detailData": {
				"jobPostingName": null,
				"hyperlink": null,
				"profileFamiliarName": null,
				"color": null,
				"companyName": {
					"name": "European Commission",
					"entityUrn": "urn:li:fsd_company:1809",
					"url": "https://www.linkedin.com/company/european-commission/"
				},
				"icon": null,
				"epoch": null,
				"systemImage": null,
				"textLink": null,
				"listItemStyle": null,
				"groupName": null,
				"hyperlinkOpenExternally": null,
				"listStyle": null,
				"profileFullName": null,
				"stringFieldReference": null,
				"learningCourseName": null,
				"profileMention": null,
				"style": null,
				"schoolName": null,
				"hashtag": null
			}
		},
		{
			"start": 50,
			"length": 13,
			"detailData": {
				"jobPostingName": null,
				"hyperlink": null,
				"profileFamiliarName": null,
				"color": null,
				"companyName": null,
				"icon": null,
				"epoch": null,
				"systemImage": null,
				"textLink": null,
				"listItemStyle": null,
				"groupName": null,
				"hyperlinkOpenExternally": null,
				"listStyle": null,
				"profileFullName": null,
				"stringFieldReference": null,
				"learningCourseName": null,
				"profileMention": {
					"firstName": "Johan",
					"lastName": "Falkman",
					"entityUrn": "urn:li:fsd_profile:ACoAAAGYg5EBEm2l3FbYNPTUIZXHA2B1Ic2mgLI",
					"publicIdentifier": "johan-falkman-329b718"
				},
				"style": null,
				"schoolName": null,
				"hashtag": null
			}
		}
	],
	"fromPostAuthor": false,
	"comments": [
		{
			"time": 1673543758539,
			"formattedTime": "2023-01-12T17:15:58.539Z",
			"link": "https://www.linkedin.com/feed/update/urn:li:activity:7019294467031543808?commentUrn=urn%3Ali%3Acomment%3A%28activity%3A7019294467031543808%2C7019338509924597761%29&replyUrn=urn%3Ali%3Acomment%3A%28activity%3A7019294467031543808%2C7019351280607207424%29&dashCommentUrn=urn%3Ali%3Afsd_comment%3A%287019338509924597761%2Curn%3Ali%3Aactivity%3A7019294467031543808%29&dashReplyUrn=urn%3Ali%3Afsd_comment%3A%287019351280607207424%2Curn%3Ali%3Aactivity%3A7019294467031543808%29",
			"text": "Yes, a miss by the Commission not to mention forest products.",
			"entities": [],
			"fromPostAuthor": false,
			"urn": "urn:li:comment:(activity:7019294467031543808,7019351280607207424)",
			"pinned": false,
			"edited": false,
			"numComments": 0,
			"numImpressions": null,
			"numShares": null,
			"reactionTypeCounts": {
				"LIKE": 1
			},
			"author": {
				"distance": "3rd+",
				"name": "Johan Falkman",
				"firstName": "Johan",
				"lastName": "Falkman",
				"id": "26772369",
				"profileUrl": "https://www.linkedin.com/in/johan-falkman-329b718",
				"profileId": "ACoAAAGYg5EBEm2l3FbYNPTUIZXHA2B1Ic2mgLI",
				"publicId": "johan-falkman-329b718",
				"picture": "https://media.licdn.com/dms/image/v2/D4D03AQFbRxDZ6d4RDA/profile-displayphoto-shrink_100_100/profile-displayphoto-shrink_100_100/0/1694631789158?e=1736380800&v=beta&t=3rVnQLIkCjeH_h0I7tU_xmVtCXgfzkHDh1JdhniKx1k"
			}
		}
	],
	"urn": "urn:li:comment:(activity:7019294467031543808,7019338509924597761)",
	"pinned": false,
	"edited": false,
	"numComments": 1,
	"numImpressions": null,
	"numShares": null,
	"reactionTypeCounts": {
		"LIKE": 2
	},
	"author": {
		"distance": "3rd+",
		"name": "Jan-Erik Gasslander",
		"firstName": "Jan-Erik",
		"lastName": "Gasslander",
		"id": "281118555",
		"profileUrl": "https://www.linkedin.com/in/jan-erik-gasslander-4231907a",
		"profileId": "ACoAABDBh1sBFusnDeby5SWQnyZ3z2lu1_Y7ji4",
		"publicId": "jan-erik-gasslander-4231907a"
	},
	"postId": "urn:li:activity:7019294467031543808"
}
````

# Actor input Schema

## `postUrl` (type: `string`):

Click on 3 dots menu of the post, and then click on 'Copy link to post' option to get the URL

## `sortType` (type: `string`):

No description

## `startPage` (type: `integer`):

Page number to start scraping

## `count` (type: `integer`):

Leave this field empty if you want to scrape all items.

## `cookies` (type: `array`):

Cookies are used to authorize the actor with linkedin.com<br><br> Follow these steps to get the cookies: <ol> <li>Install [Cookie-Editor](https://chromewebstore.google.com/detail/cookie-editor/hlkenndednhfkekhgcdicdfddnkalmdm) chrome extension</li> <li> Login to your linkedin.com account </li> <li> Click on the extension and export the linkedin cookies </li> <li>Paste the copied contents here</li> </ol> <p> \<a href=https://youtu.be/YuKp9BlVgNM target=\_blank>\<img src=https://www.youtube.com/s/desktop/66e817d4/img/favicon\_32x32.png width=16px> Video - How to get cookies (0:14)</a>

## `userAgent` (type: `string`):

[Click here](https://www.google.com/search?q=my+user+agent) to get the user agent info.

## `minDelay` (type: `integer`):

Minimum duration in seconds to wait before scraping next page

## `maxDelay` (type: `integer`):

Maximum duration in seconds to wait before scraping next page

## `proxy` (type: `object`):

Choose a proxy from the country where you are logged into LinkedIn

## Actor input object example

```json
{
  "postUrl": "https://www.linkedin.com/posts/linkedin_add-job-preferences-activity-6704397478923423745-OR6o",
  "sortType": "RELEVANCE",
  "startPage": 1,
  "minDelay": 2,
  "maxDelay": 7,
  "proxy": {
    "useApifyProxy": true,
    "apifyProxyCountry": "US"
  }
}
```

# 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 = {
    "postUrl": "https://www.linkedin.com/posts/linkedin_add-job-preferences-activity-6704397478923423745-OR6o",
    "sortType": "RELEVANCE",
    "startPage": 1,
    "minDelay": 2,
    "maxDelay": 7,
    "proxy": {
        "useApifyProxy": true,
        "apifyProxyCountry": "US"
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("curious_coder/linkedin-comment-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 = {
    "postUrl": "https://www.linkedin.com/posts/linkedin_add-job-preferences-activity-6704397478923423745-OR6o",
    "sortType": "RELEVANCE",
    "startPage": 1,
    "minDelay": 2,
    "maxDelay": 7,
    "proxy": {
        "useApifyProxy": True,
        "apifyProxyCountry": "US",
    },
}

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

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

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

```

## CLI example

```bash
echo '{
  "postUrl": "https://www.linkedin.com/posts/linkedin_add-job-preferences-activity-6704397478923423745-OR6o",
  "sortType": "RELEVANCE",
  "startPage": 1,
  "minDelay": 2,
  "maxDelay": 7,
  "proxy": {
    "useApifyProxy": true,
    "apifyProxyCountry": "US"
  }
}' |
apify call curious_coder/linkedin-comment-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=curious_coder/linkedin-comment-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Linkedin comment scraper",
        "description": "Scrape comments from any linkedin post with following details: Comment text, Comment author details, Total Likes, Total replies, etc",
        "version": "1.0",
        "x-build-id": "F6MDuriiQjmCoVd3u"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/curious_coder~linkedin-comment-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-curious_coder-linkedin-comment-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/curious_coder~linkedin-comment-scraper/runs": {
            "post": {
                "operationId": "runs-sync-curious_coder-linkedin-comment-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/curious_coder~linkedin-comment-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-curious_coder-linkedin-comment-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "cookies",
                    "userAgent",
                    "postUrl",
                    "proxy"
                ],
                "properties": {
                    "postUrl": {
                        "title": "Link to linkedin post",
                        "type": "string",
                        "description": "Click on 3 dots menu of the post, and then click on 'Copy link to post' option to get the URL"
                    },
                    "sortType": {
                        "title": "Sorting",
                        "enum": [
                            "RELEVANCE",
                            "RECENT"
                        ],
                        "type": "string",
                        "description": "",
                        "default": "RELEVANCE"
                    },
                    "startPage": {
                        "title": "Start page",
                        "type": "integer",
                        "description": "Page number to start scraping",
                        "default": 1
                    },
                    "count": {
                        "title": "#️⃣ Total number of records required",
                        "type": "integer",
                        "description": "Leave this field empty if you want to scrape all items."
                    },
                    "cookies": {
                        "title": "🍪 Cookies",
                        "type": "array",
                        "description": "Cookies are used to authorize the actor with linkedin.com<br><br> Follow these steps to get the cookies: <ol> <li>Install [Cookie-Editor](https://chromewebstore.google.com/detail/cookie-editor/hlkenndednhfkekhgcdicdfddnkalmdm) chrome extension</li> <li> Login to your linkedin.com account </li> <li> Click on the extension and export the linkedin cookies </li> <li>Paste the copied contents here</li> </ol> <p> <a href=https://youtu.be/YuKp9BlVgNM target=_blank><img src=https://www.youtube.com/s/desktop/66e817d4/img/favicon_32x32.png width=16px> Video - How to get cookies (0:14)</a>"
                    },
                    "userAgent": {
                        "title": "User agent",
                        "type": "string",
                        "description": "[Click here](https://www.google.com/search?q=my+user+agent) to get the user agent info."
                    },
                    "minDelay": {
                        "title": "⏱️ Minimum wait duration",
                        "minimum": 2,
                        "type": "integer",
                        "description": "Minimum duration in seconds to wait before scraping next page",
                        "default": 2
                    },
                    "maxDelay": {
                        "title": "⏱️ Maximum wait duration",
                        "minimum": 5,
                        "type": "integer",
                        "description": "Maximum duration in seconds to wait before scraping next page",
                        "default": 7
                    },
                    "proxy": {
                        "title": "Proxy",
                        "type": "object",
                        "description": "Choose a proxy from the country where you are logged into LinkedIn"
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
