Skip to main content

Youtube Crawler

How To Use Youtube Comment Downloader

To scrapping data from youtube. there are several tools that can be used. one of them is youtube comment downloader. This library using the python as base programming language

How To Use

  1. First thing, is you need to make sure that python is already installed in your device. Can used both Python 2 or Python 3
  2. Next is make sure you already install the dependencies library, I recommend PIP Package Manager to install the dependencies
  3. After that, you can run the script using the command line, can use from visual code editor like visual studio code or just running from the terminal
  4. How to use the library as simple as creating new python files like web-scrapping.py and then you can use the following code
    from itertools import islice
    from youtube_comment_downloader import *
    downloader = YoutubeCommentDownloader()
    comments = downloader.get_comments_from_url('https://www.youtube.com/watch?v=ScMzIvxBSi4', sort_by=SORT_BY_POPULAR)
    for comment in islice(comments, 10):
    print(comment)
    Can run the code by just using
    python web-scrapping.py
  5. Then this will output json file like this
    {
    "text": "The way Matty sings 'I'm sorry that I'm kinda queer, it's not as weird as it appears' breaks my heart every single time",
    "author": "Sarah Mitchell",
    "cid": "UgxK9Z2_3QjH8V2xPp14AaABAg",
    "votes": 15243,
    "time": "2 months ago",
    "timestamp": 1642046400,
    "heart": true,
    "reply_count": 89
    }
    {
    "text": "This song perfectly captures that feeling of being young, lost and trying to figure out who you are. The 1975 just gets it.",
    "author": "James Wilson",
    "cid": "Ugw9X7B_2PkH7V1xPp14AaABAg",
    "votes": 12876,
    "time": "3 months ago",
    "timestamp": 1639368000,
    "heart": false,
    "reply_count": 45
    }
    {
    "text": "'And you're making a mistake, the same mistakes my parents made' - this line hits differently now that I'm older",
    "author": "Emma Thompson",
    "cid": "UgxK9Z2_3QjH8V2xPp14AaABAg",
    "votes": 9654,
    "time": "1 month ago",
    "timestamp": 1644638400,
    "heart": false,
    "reply_count": 23
    }
    {
    "text": "The production on this track is incredible. The way the synths blend with Matty's vocals in the chorus is pure genius",
    "author": "David Chen",
    "cid": "UgxR7B2_3QjH8V2xPp14AaABAg",
    "votes": 8765,
    "time": "2 months ago",
    "timestamp": 1642046400,
    "heart": false,
    "reply_count": 15
    }
    {
    "text": "Been following The 1975 since their EP days and it's amazing to see how they've evolved while keeping their core sound intact",
    "author": "Lucy Parker",
    "cid": "UgxT9Z2_3QjH8V2xPp14AaABAg",
    "votes": 7654,
    "time": "1 month ago",
    "timestamp": 1644638400,
    "heart": true,
    "reply_count": 67
    }
    {
    "text": "George Daniel's drumming on this track is so underrated. The way he builds tension in the bridge is masterful",
    "author": "Michael Roberts",
    "cid": "UgxY9Z2_3QjH8V2xPp14AaABAg",
    "votes": 6543,
    "time": "3 months ago",
    "timestamp": 1639368000,
    "heart": false,
    "reply_count": 12
    }
    {
    "text": "Adam Hann's guitar work in the background adds so much depth to this song. The subtle riffs are perfect",
    "author": "Hannah Smith",
    "cid": "UgxZ9Z2_3QjH8V2xPp14AaABAg",
    "votes": 5432,
    "time": "2 months ago",
    "timestamp": 1642046400,
    "heart": false,
    "reply_count": 8
    }
    {
    "text": "Ross MacDonald's bassline is the unsung hero of this track. It's what gives the song its groove",
    "author": "Tom Williams",
    "cid": "UgxW9Z2_3QjH8V2xPp14AaABAg",
    "votes": 4321,
    "time": "1 month ago",
    "timestamp": 1644638400,
    "heart": false,
    "reply_count": 19
    }
    {
    "text": "The way this song transitions from the verse to the chorus is pure art. Only The 1975 could pull this off",
    "author": "Sophie Turner",
    "cid": "UgxV9Z2_3QjH8V2xPp14AaABAg",
    "votes": 3210,
    "time": "2 months ago",
    "timestamp": 1642046400,
    "heart": false,
    "reply_count": 5
    }
    {
    "text": "This song reminds me of driving around at night with friends during summer. Perfect vibes",
    "author": "Ryan Johnson",
    "cid": "UgxU9Z2_3QjH8V2xPp14AaABAg",
    "votes": 2109,
    "time": "3 months ago",
    "timestamp": 1639368000,
    "heart": false,
    "reply_count": 31
    }
  6. After that. we need to import the json file to google sheet or microsoft excel. we can use tools from google sheet alt text
  7. Done. the json will successfully turn into google sheet