Back to Blog
YouTube

YouTube Comment Scraper: Analyze Viewer Sentiment & Feedback

November 28, 2025
3 min read
S
By SociaVault Team
YouTubeCommentsSentiment AnalysisScraping

If you have a viral video, you might get 5,000+ comments.

Reading them all is impossible. But ignoring them means missing out on:

  1. Video Ideas: "Can you do a part 2 on X?"
  2. Bug Reports: "The audio is out of sync at 2:30."
  3. Sentiment: "I usually love your stuff, but this one felt rushed."

In this guide, we'll build a YouTube Comment Analyzer using SociaVault. We'll scrape the comments from a video and automatically categorize them.

The Strategy

We will write a script that:

  1. Takes a YouTube video URL.
  2. Scrapes the top 100 comments.
  3. Filters for Questions (potential video topics).
  4. Filters for Sentiment (positive vs negative).

Prerequisites

You'll need a SociaVault API key. You can get one here.

Step 1: Scrape the Comments

We'll use the /scrape/youtube/video/comments endpoint.

const axios = require('axios');

const API_KEY = 'YOUR_SOCIAVAULT_API_KEY';
const BASE_URL = 'https://api.sociavault.com/v1';

async function getVideoComments(videoUrl) {
  console.log(`šŸ“„ Fetching comments for: ${videoUrl}`);

  try {
    const response = await axios.get(`${BASE_URL}/scrape/youtube/video/comments`, {
      params: { 
        url: videoUrl,
        order: 'top' // Get top comments first
      },
      headers: { 'x-api-key': API_KEY }
    });

    if (response.data.success) {
      return response.data.data;
    }
  } catch (error) {
    console.error("Error fetching comments:", error.message);
    return [];
  }
}

Step 2: Find Video Ideas (Questions)

The most valuable comments are questions. They literally tell you what to make next.

function findQuestions(comments) {
  const questions = comments.filter(c => c.text.includes('?'));
  
  console.log(`\nā“ Found ${questions.length} Questions:`);
  questions.slice(0, 5).forEach(q => {
    console.log(`   - "${q.text}" (by ${q.author})`);
  });
}

Step 3: Analyze Sentiment

Let's do a quick "Vibe Check" on the comments.

function analyzeSentiment(comments) {
  let positive = 0;
  let negative = 0;

  comments.forEach(c => {
    const text = c.text.toLowerCase();
    if (text.includes('love') || text.includes('great') || text.includes('awesome')) positive++;
    if (text.includes('hate') || text.includes('bad') || text.includes('boring')) negative++;
  });

  console.log(`\nšŸ“Š Sentiment Analysis:`);
  console.log(`   šŸ‘ Positive: ${positive}`);
  console.log(`   šŸ‘Ž Negative: ${negative}`);
  
  const ratio = positive / (positive + negative || 1);
  console.log(`   šŸ“ˆ Positivity Ratio: ${(ratio * 100).toFixed(1)}%`);
}

Putting It All Together

async function analyzeVideo(url) {
  const comments = await getVideoComments(url);
  
  if (comments.length > 0) {
    console.log(`āœ… Successfully scraped ${comments.length} comments.`);
    findQuestions(comments);
    analyzeSentiment(comments);
  }
}

// Example: Analyze a MrBeast video
analyzeVideo('https://www.youtube.com/watch?v=0e3GPea1Tyg');

Sample Output

šŸ“„ Fetching comments for: https://www.youtube.com/watch?v=0e3GPea1Tyg
āœ… Successfully scraped 85 comments.

ā“ Found 12 Questions:
   - "When is the next challenge coming out?" (by User123)
   - "How much did this cost to make?" (by FanBoy)
   - "Can you do a video with PewDiePie?" (by GamerX)

šŸ“Š Sentiment Analysis:
   šŸ‘ Positive: 45
   šŸ‘Ž Negative: 3
   šŸ“ˆ Positivity Ratio: 93.8%

Why This Matters

If you are a brand or creator, your comments section is a focus group that runs 24/7.

By automating this analysis, you can:

  1. Reply Faster: Filter for questions and answer them immediately to boost engagement.
  2. Spot Issues: If the "Negative" count spikes, investigate immediately.
  3. Plan Content: Use the questions to build your content calendar for next month.

Get Started

Stop guessing what your viewers want. Get your API key here.

Found this helpful?

Share it with others who might benefit

Ready to Try SociaVault?

Start extracting social media data with our powerful API. No credit card required.