How to Scrape TikTok: Scrape Profile Stats and Videos
Article

How to Scrape TikTok: Scrape Profile Stats and Videos

Engineering

Learn how to scrape TikTok profile stats and videos using Python and Playwright. Extract followers, likes, bios, and video data reliably from dynamic TikTok pages.

Short-form video content is exploding in popularity, and platforms like TikTok have become essential sources of marketing insights, competitor analysis, trend tracking, and audience behavior analytics.

But unlike many traditional websites, TikTok is almost entirely dynamic — meaning you cannot scrape it reliably with basic HTTP requests or BeautifulSoup.

To extract meaningful data such as:

  • Profile username & display name
  • Bio description
  • Followers / following / likes
  • Recent videos
  • Video captions
  • Video URLs
  • View count, likes, comments

…you need a scraping tool capable of executing JavaScript and simulating real browser behavior.

In this tutorial, you’ll learn how to scrape TikTok profile stats and videos using Python + Playwright, one of the most powerful browser automation tools available.

Why Scraping TikTok Is Harder Than It Looks

Scraping TikTok is more complex than scraping most websites due to:

1. JavaScript-heavy content

TikTok renders almost everything dynamically, including numbers that only appear after scrolling.

2. Anti-bot challenges

TikTok detects automated requests and blocks them.

3. Dynamic CSS selectors

Class names often change, breaking fragile scrapers.

4. Rate limiting & region checks

TikTok may show:

  • “Something went wrong”
  • Blank pages
  • Redirection loops

This is why Requests, Axios, Curl, or BeautifulSoup fail entirely — they cannot render the page.

Playwright, however, loads TikTok like a real user.

Why Playwright Works Best for TikTok Scraping

Playwright (by Microsoft) is ideal because it supports:

  • Real Chromium browser engine
  • Automatic JavaScript execution
  • Anti-bot resistance
  • Scroll automation
  • Modern CSS selector support
  • Stable dynamic DOM handling

This makes it the most resilient tool for TikTok data extraction.

What We Will Scrape in This Tutorial

Given a TikTok profile URL like:


[https://www.tiktok.com/@therock](https://www.tiktok.com/@therock)

We will extract:

  • Username
  • Display name
  • Bio text
  • Follower count
  • Following count
  • Total likes
  • Recent videos
  • Video captions
  • Video URLs

All results will be returned in one JSON object.

Full Python Code: Scraping TikTok Profiles with Playwright

This script:

  • Launches Chromium
  • Navigates to a TikTok profile
  • Waits for dynamic content
  • Extracts profile stats
  • Scrolls to load videos
  • Extracts each video’s metadata

Replace the URL with any TikTok profile.

from playwright.sync_api import sync_playwright
import time

# TikTok profile URL example
PROFILE_URL = "https://www.tiktok.com/@therock"  # change to any profile


def scrape_tiktok_profile(url):
    with sync_playwright() as p:
        browser = p.chromium.launch(headless=False)  # True = headless
        context = browser.new_context(
            user_agent=(
                "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
                "AppleWebKit/537.36 (KHTML, like Gecko) "
                "Chrome/120.0.0.0 Safari/537.36"
            )
        )
        page = context.new_page()

        print("Navigating to TikTok profile...")
        page.goto(url, timeout=60000, wait_until="networkidle")

        # Wait for header to load
        try:
            page.wait_for_selector("h1[data-e2e='user-title']", timeout=10000)
        except:
            print("Failed to load TikTok profile. Blocked or invalid URL.")
            browser.close()
            return None

        # Helper
        def safe_text(selector):
            try:
                return page.locator(selector).inner_text().strip()
            except:
                return None

        profile = {
            "username": safe_text("h1[data-e2e='user-title']"),
            "display_name": safe_text("h2[data-e2e='user-subtitle']"),
            "bio": safe_text("h2[data-e2e='user-bio']"),
            "following": safe_text("strong[data-e2e='following-count']"),
            "followers": safe_text("strong[data-e2e='followers-count']"),
            "likes": safe_text("strong[data-e2e='likes-count']"),
        }

        # Scroll to load videos
        print("Scrolling to load videos...")
        for _ in range(4):  # Increase for more videos
            page.mouse.wheel(0, 3000)
            time.sleep(1.2)

        # Extract video metadata
        print("Extracting videos...")
        videos = []
        video_items = page.locator("div[data-e2e='user-post-item']").all()

        for item in video_items:
            try:
                caption = item.locator("div[data-e2e='user-post-item-desc']").inner_text()
            except:
                caption = None

            try:
                link = item.locator("a").get_attribute("href")
            except:
                link = None

            videos.append({
                "caption": caption,
                "url": link
            })

        profile["videos"] = videos

        browser.close()
        return profile


# Run scraper
data = scrape_tiktok_profile(PROFILE_URL)
print("\nScraped TikTok Profile Data:\n", data)

Example Output

{
  "username": "therock",
  "display_name": "Dwayne Johnson",
  "bio": "Mana. Gratitude. Tequila.",
  "following": "345",
  "followers": "77.2M",
  "likes": "512.4M",
  "videos": [
    {
      "caption": "Monday motivation 💪",
      "url": "https://www.tiktok.com/@therock/video/723498..."
    },
    {
      "caption": "New energy drink drop! ⚡",
      "url": "https://www.tiktok.com/@therock/video/724209..."
    }
  ]
}

This gives you essential profile data for analytics, competitive research, dashboards, and monitoring.

Bonus: Want Easier Scraping Without Playwright?

Playwright works great, but scraping TikTok long-term usually requires:

  • Proxy rotation
  • CAPTCHA handling
  • Residential IPs
  • Session cookies
  • Cloud browser execution

If you want a zero-maintenance solution, MrScraper can extract:

  • TikTok profiles
  • TikTok videos
  • Hashtag results
  • Comments
  • Engagement stats

—without dealing with browser automation.

Conclusion

Scraping TikTok isn’t possible with simple HTTP requests — the platform is fully dynamic and heavily protected. Using Playwright allows you to:

  • Load JavaScript
  • Scroll through video feeds
  • Extract profile and video data
  • Handle most anti-bot challenges

With the script above, you now have a reliable TikTok scraper that collects followers, engagement metrics, bios, and video metadata.

For an easier alternative, MrScraper provides a scalable TikTok scraper without proxies or browser setup.

Table of Contents

    Take a Taste of Easy Scraping!