How to Get YouTube Keywords In Python using Pytube?

  In this section, we will learn how to download youtube keywords in python using pytube.

Prerequisite

Pytube is a very serious, lightweight, dependency-free Python library (and command-line utility) for downloading YouTube Videos. There are various YouTube API avaible to get the meta data of YouTube Videos.

Required Module

In this tutorial, we are using the Pytube Module of Python. You can download it using PIP in python.

												
pip install pytube
												
												
											

Approach

  1. Import the pytube module.
  2. Create and initialize an object of YouTube() e.g, src = YouTube(url).
  3. To get a list of keywords you need to create a variable called keywords_list, e.g. list_of_keywords = src.keywords;
  4. When you access the list of keywords using an src object, it returns the list of keywords of a given YouTube video.
  5. Display the list of keywords. e.g. print(list_of_keywords)

Pytube program implementation given below.



Program: Get YouTube Keywords Using Pytube

												
"""
Created on Tue May 18 20:01:47 2021

@author: www.codenaive.com
"""

# AIM:  How to get YouTube Keywords using Python?

# Import Pytube module to use API
from pytube import YouTube

url = 'https://youtu.be/mBJMkFNRVek'

# create an object of YouTube() and pass the  URL of YouTube Videos
src = YouTube(url)

# get the keywords of given video 
list_of_keywords = src.keywords;

# display the list of keywords
print("List of All keywords: ")
print(list_of_keywords)
												
												
											


Output

Pytube YouTube Keywords Output SRT Pytube Codenaive
Pytube YouTube Keywords Output.
Announcement

Advertisement