Skip to main content

A python library to scrape video's comments data from youtube automatically.

Project description

Youtube-Comment-Scraper-Python is a python library to fetch video comments on youtube using browser automation. It currently runs only on windows.

Example1

In this example we first import library, then we will open the video and fetch comments one time only.

from youtube_comment_scraper_python import *
youtube.open("https://www.youtube.com/watch?v=C5duQyX7Gec")
response=youtube.video_comments()
data=response['body']
#data=[{"Comment": "This planet belongs to all of us ", "UserLink": "https://www.youtube.com/channel/UCpH24tSZnFGAECI_ZCa7jJQ", "user": "
Mohd Haris", "Time": "14 hours ago", "Likes": "23"}]

Example2:- Load More Comments

In this example we first import library, then we will open the video and fetch the comments five times, as it scrolls whenever function called.

from youtube_comment_scraper_python import *
youtube.open("https://www.youtube.com/watch?v=C5duQyX7Gec")
all_data=[]
for i in range(0,5):
	response=youtube.video_comments()
	data=response['body']
	all_data.extend(data)
#data=[{"Comment": "This planet belongs to all of us ", "UserLink": "https://www.youtube.com/channel/UCpH24tSZnFGAECI_ZCa7jJQ", "user": "
Mohd Haris", "Time": "14 hours ago", "Likes": "23"}]

This module depends on the following python modules

BotStudio

bot_studio is needed for browser automation. As soon as this library is imported in code, automated browser will open up in which video will be opend and comments will be fetched.

Complete documentation for YouTube Automation available here

Installation

pip install youtube-comment-scraper-python

Import

from youtube_comment_scraper_python import *

Login with credentials

youtube.login(username="youtube username",password="youtube password")

Login with cookies

youtube.login_cookie(cookies=list_of_cookies)

Open video link

youtube.open("video link")

Get comments

response=youtube.video_comments()
data=response['body']

Send Feedback to Developers

bot_studio.send_feedback(feedback="Need help with this ......")

Contact Us

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

youtube-comment-scraper-python-1.0.0.tar.gz (2.6 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page