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.
Table of Contents
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
- Import the pytube module.
- Create and initialize an object of YouTube() e.g, src = YouTube(url).
- To get a list of keywords you need to create a variable called keywords_list, e.g. list_of_keywords = src.keywords;
- When you access the list of keywords using an src object, it returns the list of keywords of a given YouTube video.
- 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

Leave a Reply