How I scraped LinkedIn posts without getting banned

Session cookies (li_at, JSESSIONID) injected in Selenium, search URL by topic, simulated scrolling with random waits, parse posts with BeautifulSoup, extract URN, link, text, date, likes, reposts, hashtags, store in Supabase. Anti-bot tips.

playbook
Last updated Nov 21, 2026

Tools featured in this playbook

(And What I Learned)

RPP

RPP

4 min read

·

Apr 29, 2025

--

--

Press enter or click to view image in full size

Photo by John Schnobrich on Unsplash

Hey everyone! 👋

I’m rpp. My name’s a little long, but you can just call me rpp.

This is actually my first article ever, so go easy on me! 😊

A few months ago, I hit a roadblock: I needed real-world insights from LinkedIn posts for a project, but every article or tool I found focused only on scraping jobs or emails.

Nobody was talking about scraping LinkedIn posts.

So, I rolled up my sleeves and figured it out myself — safely, efficiently, and without losing my account.

In this article, I’ll break down:

  • Why scraping LinkedIn posts is valuable

  • The tech stack I used

  • How to bypass LinkedIn’s bot detection

  • Lessons I learned the hard way

Let’s dive right in. 🚀

Why Scraping LinkedIn Posts Matters

Everyone scrapes LinkedIn for jobs or emails. But the real gold?

It’s in the posts.

People share:

  • New trends

  • Industry news

  • Product launches

  • Honest professional opinions

If you’re a founder, researcher, or marketer, scraping posts gives you access to fresh, organic market signals — not outdated resumes.

Tools and Technologies I Used

Here’s my setup:

+----------------------+----------------------------+| Tool                 | Purpose                    |+----------------------+----------------------------+| Python               | Main scripting language    || Selenium             | Browser automation         || BeautifulSoup        | Parsing HTML               || Supabase             | Storing scraped data       || ChromeDriver         | Driving Chrome             || Session Cookies      | Staying logged in          || dotenv, time, random | Helper libraries           |+----------------------+----------------------------+

✅ Pro Tip:

Install everything at once with:

pip install selenium beautifulsoup4 python-dotenv supabase

Before You Scrape: Essential Setup

1. Get LinkedIn Session Cookies

  • You need li_at and JSESSIONID.

  • Extract them using Chrome DevTools or a browser extension.

  • This makes LinkedIn think you’re still logged in — no password needed.

2. Setup Selenium Correctly

  • Download the right ChromeDriver for your Chrome version.

  • Write a function like this to inject cookies:

def load_session_cookies(driver, cookies):driver.get('https://www.linkedin.com')for cookie in cookies:driver.add_cookie(cookie)driver.refresh()

✅ Pro Tip:

Always refresh the page after adding cookies!

How to Scrape LinkedIn Posts (Step-by-Step)

1. Target the Search Page

Search by topic using a URL like:

Get RPP’s stories in your inbox

Join Medium for free to get updates from this writer.

Remember me for faster sign in

https://www.linkedin.com/search/results/content/?keywords=YOUR_TOPIC

2. Simulate Scrolling

Use Selenium’s execute_script method:

driver.execute_script("window.scrollBy(0, document.body.scrollHeight);")

Add random sleeps between scrolls to act human.

3. Parse Page Content

Use BeautifulSoup to find posts:

soup = BeautifulSoup(driver.page_source, 'html.parser')posts = soup.find_all('div', attrs={"data-view-name": "feed-full-update"})

4. Extract Data

From each post, grab:

  • Post ID (URN)

  • Post link

  • Description

  • Timestamp

  • Likes count

  • Reposts count

  • Hashtags

Save the results into a JSON, CSV, or directly into your database.

✅ Pro Tip:

LinkedIn’s HTML structure changes often. Always double-check the div classes before scraping!

Staying Under the Radar (Bot Detection Tricks)

LinkedIn is smart. You have to be smarter.

✅ Randomize wait times:

time.sleep(random.randint(2,5))

✅ Scroll inconsistently — fast sometimes, slow other times.

✅ Refresh the page periodically to reset behavior patterns.

✅ Don’t run scrapers 24/7. Humans sleep too. 😴

✅ Limit scraping speed to 2–3 posts per minute at maximum.

✅ Rotate User Agents if needed (for bigger projects).

Real Challenges I Faced

  • LinkedIn’s DOM is messy Many elements are nested deep, often with random IDs. Solution: Manually inspect the structure every few weeks.

  • Captcha Walls If LinkedIn suspects you, you’ll get a captcha challenge. Solution: Use human-like browsing and very low scraping frequency.

  • Cookie Expiry Session cookies expire. Solution: Update them manually every few days.

Lessons Learned

🔥 Scraping LinkedIn is way harder than scraping Instagram or Twitter

Their anti-bot tech is next-level.

🔥 Human behavior is the best bot defense

If your scraper acts like a human, it survives.

🔥 Manual debugging beats blind coding

Spend time manually inspecting HTML. No parser can save you from constantly changing frontends.

🔥 Patience wins

Slow scrapers live longer. Don’t rush.

🔥 Respect the platform

Always scrape ethically — don’t overload their servers.

Final Thoughts

When I started this project, I found zero good guides on scraping LinkedIn posts.

It was a grind, but I’m glad I stuck through it — the insights I unlocked were absolutely worth it.

If you’re thinking about building your own professional data gathering tool, start small, scrape ethically, and learn as you go.

This article was originally posted on Medium

Comments

Login to leave a comment