ScavioScavio
FeaturesPricingDocs
Sign InGet Started
  1. Home
  2. Tutorials
  3. How to Scrape LinkedIn Post Comments
Tutorial

How to Scrape LinkedIn Post Comments

Discover LinkedIn posts and extract comment engagement for lead enrichment. Uses Google SERP indexing to avoid LinkedIn anti-scraping blocks.

Get Free API KeyAPI Docs

LinkedIn is the highest-signal B2B dataset online, and comments on target-persona posts are gold for GTM teams. Direct LinkedIn scraping triggers bans, but Google SERP indexes LinkedIn posts cooperatively. This tutorial shows how to use Scavio to discover posts by topic, then fetch the post page and extract comment-level signal for CRM enrichment.

Prerequisites

  • Python 3.8+
  • requests library
  • A Scavio API key
  • A target LinkedIn topic or persona (e.g. 'SDR strategy')

Walkthrough

Step 1: Search Google for LinkedIn posts

Use a site operator to restrict results to linkedin.com/posts.

Python
import requests, os
r = requests.post('https://api.scavio.dev/api/v1/search',
    headers={'x-api-key': os.environ['SCAVIO_API_KEY']},
    json={'query': 'site:linkedin.com/posts "SDR strategy" 2026'})
posts = r.json()['organic_results']

Step 2: Filter to post URLs

Keep only URLs that point to actual LinkedIn posts.

Python
post_urls = [p['link'] for p in posts if '/posts/' in p['link']]

Step 3: Fetch each post page

Use Scavio's page extractor to pull the rendered post content.

Python
def fetch_post(url):
    r = requests.post('https://api.scavio.dev/api/v1/extract',
        headers={'x-api-key': os.environ['SCAVIO_API_KEY']},
        json={'url': url, 'render_js': True})
    return r.json()

Step 4: Extract reactions and commenters

Parse the extracted HTML or structured data for commenter names and engagement.

Python
from bs4 import BeautifulSoup

def extract_engagement(html):
    soup = BeautifulSoup(html, 'html.parser')
    commenters = [el.text.strip() for el in soup.select('[data-test-commenter]')]
    return {'commenters': commenters, 'count': len(commenters)}

Step 5: Enrich into CRM

Push the commenter list into your enrichment pipeline.

Python
for post_url in post_urls[:10]:
    post = fetch_post(post_url)
    engagement = extract_engagement(post.get('html', ''))
    print(post_url, engagement['count'], 'commenters')

Python Example

Python
import os, requests

API_KEY = os.environ['SCAVIO_API_KEY']

def linkedin_posts(topic, limit=10):
    r = requests.post('https://api.scavio.dev/api/v1/search',
        headers={'x-api-key': API_KEY},
        json={'query': f'site:linkedin.com/posts "{topic}"'})
    return [p['link'] for p in r.json()['organic_results'] if '/posts/' in p['link']][:limit]

def fetch_post(url):
    r = requests.post('https://api.scavio.dev/api/v1/extract',
        headers={'x-api-key': API_KEY},
        json={'url': url, 'render_js': True})
    return r.json()

if __name__ == '__main__':
    for url in linkedin_posts('SDR strategy'):
        post = fetch_post(url)
        print(url, '- extracted', len(post.get('html', '')), 'chars')

JavaScript Example

JavaScript
const API_KEY = process.env.SCAVIO_API_KEY;

async function linkedinPosts(topic, limit = 10) {
  const r = await fetch('https://api.scavio.dev/api/v1/search', {
    method: 'POST',
    headers: { 'x-api-key': API_KEY, 'Content-Type': 'application/json' },
    body: JSON.stringify({ query: `site:linkedin.com/posts "${topic}"` })
  });
  const { organic_results } = await r.json();
  return organic_results.filter(p => p.link.includes('/posts/')).slice(0, limit).map(p => p.link);
}

const posts = await linkedinPosts('SDR strategy');
console.log(`Found ${posts.length} LinkedIn posts`);

Expected Output

JSON
Found 10 LinkedIn post URLs matching 'SDR strategy'. For each URL, Scavio extracts the rendered page HTML with commenter names and reaction counts. You now have a list of engaged LinkedIn users to enrich into your CRM.

Related Tutorials

  • How to Build an SDR Research Agent
  • How to Track AI Brand Mentions in ChatGPT

Frequently Asked Questions

Most developers complete this tutorial in 15 to 30 minutes. You will need a Scavio API key (free tier works) and a working Python or JavaScript environment.

Python 3.8+. requests library. A Scavio API key. A target LinkedIn topic or persona (e.g. 'SDR strategy'). A Scavio API key gives you 250 free credits per month.

Yes. The free tier includes 250 credits per month, which is more than enough to complete this tutorial and prototype a working solution.

Scavio has a native LangChain package (langchain-scavio), an MCP server, and a plain REST API that works with any HTTP client. This tutorial uses the raw REST API, but you can adapt to your framework of choice.

Related Resources

Best Of

Best LinkedIn Data API in 2026

Read more
Best Of

Best Lead Enrichment API in 2026

Read more
Solution

Enrich Sales Leads with Search Data Instead of Apollo

Read more
Glossary

Local Business Data Enrichment

Read more
Solution

Get Local Business Data Without Scraping Google Maps

Read more
Use Case

API-First B2B Lead Enrichment

Read more

Start Building

Discover LinkedIn posts and extract comment engagement for lead enrichment. Uses Google SERP indexing to avoid LinkedIn anti-scraping blocks.

Get Free API KeyRead the Docs
ScavioScavio

Real-time search API for AI agents. Search every platform, not just Google.

Product

  • Features
  • Pricing
  • Dashboard
  • Affiliates

Developers

  • Documentation
  • API Reference
  • Quickstart
  • MCP Integration
  • Python SDK

Alternatives

  • Tavily Alternative
  • SerpAPI Alternative
  • Firecrawl Alternative
  • Exa Alternative

Tools

  • JSON Formatter
  • cURL to Code
  • Token Counter
  • All Tools

© 2026 Scavio. All rights reserved.

Featured on TAAFT
Terms of ServicePrivacy Policy