# 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
- **Features:** Limited permissions
- **Stats:** 1,120 total users, 3 monthly users, 0.0% runs succeeded, 25 bookmarks
- **User rating**: 2.13 out of 5 stars

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## 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

### 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

Looking for comment scrapers for other platforms? The [YouTube Comment Scraper](https://apify.com/supreme_coder/youtube-comment-scraper) extracts comments from YouTube videos with author details and reply threads. For Facebook, the [Facebook Comment Scraper](https://apify.com/curious_coder/facebook-comment-scraper) collects comments from any Facebook post including groups, pages, and profiles. To scrape Twitter/X replies, use the [Twitter Replies Scraper](https://apify.com/curious_coder/twitter-replies-scraper) which captures all replies to specific tweets.

For related LinkedIn scrapers, you can collect reactions from posts using the [LinkedIn Post Reactions Scraper](https://apify.com/curious_coder/linkedin-post-reactions-scraper), scrape posts themselves with the [LinkedIn Post Search Scraper](https://apify.com/curious_coder/linkedin-post-search-scraper), extract detailed profile information using the [LinkedIn Profile Scraper](https://apify.com/curious_coder/linkedin-profile-scraper), and get company data with the [LinkedIn Company Scraper](https://apify.com/curious_coder/linkedin-company-scraper). For finding people, try the [LinkedIn People Search Scraper](https://apify.com/curious_coder/linkedin-people-search-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"
}
```

# Changelog

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

# 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(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 '{
  "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": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,curious_coder/linkedin-comment-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/8xICdc1375BbZdgE3/builds/leWgxAgyoyhhGzVs7/openapi.json
