Python - Obtain title, views and likes of YouTube video using BeautifulSoup Last Updated : 29 Dec, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will learn how can we obtain data (like title, views, likes, dislikes etc) from any YouTube video using a Python script. For this task, we are going to use very famous library for web scraping BeautifulSoup and Requests. Modules required and Installation : Requests : Requests allows you to send HTTP/1.1 requests extremely easily. There’s no need to manually add query strings to your URLs. pip install requests Beautiful Soup: Beautiful Soup is a library that makes it easy to scrape information from web pages. It sits atop an HTML or XML parser, providing Pythonic idioms for iterating, searching, and modifying the parse tree. pip install beautifulsoup4 For a given URL of video, data scraping will be done. Then parsing of data (title, views, likes element) will be done using find() method of Beautiful Soup. It will find and store the values in the dictionary. Code : Python3 1== # importing the libraries from bs4 import BeautifulSoup import requests # creating function def scrape_info(url): # getting the request from url r = requests.get(url) # converting the text s = BeautifulSoup(r.text, "html.parser") # finding meta info for title title = s.find("span", class_="watch-title").text.replace("\n", "") # finding meta info for views views = s.find("div", class_="watch-view-count").text # finding meta info for likes likes = s.find("span", class_="like-button-renderer").span.button.text # saving this data in dictionary data = {'title':title, 'views':views, 'likes':likes} # returning the dictionary return data # main function if __name__ == "__main__": # URL of the video url ="https://www.youtube.com/watch?time_continue=17&v=2wEA8nuThj8" # calling the function data = scrape_info(url) # printing the dictionary print(data) Output: {'title': ' Placement100 | GeeksforGeeks ', 'views': '18, 964 views', 'likes': '37'} Comment More infoAdvertise with us Next Article Python - Obtain title, views and likes of YouTube video using BeautifulSoup R rakshitarora Follow Improve Article Tags : Python Web Technologies Python-requests Python-BS3 Web-scraping Python web-scraping-exercises +2 More Practice Tags : python Similar Reads GUI to get views, likes, and title of a YouTube video using YouTube API in Python Prerequisite: YouTube API, Tkinter Python offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with Tkinter is the fastest and e 2 min read Extract Video Titles with the Youtube API in Python Extracting video titles from YouTube can be incredibly useful for various applications, such as data analysis, content creation, and trend tracking. The YouTube Data API provides a robust way to interact with YouTube's platform and extract this information. This guide will walk you through the proce 4 min read Playing Youtube Video using Python In this article, we will see how we can play youtube video in python. In order to play youtube videos in python we need pafy and vlc module. Pafy is a Python library to download YouTube content and retrieve metadata. Below is the command to install pafy pip install pafy VLC : is a python library to 2 min read Scraping Reddit with Python and BeautifulSoup In this article, we are going to see how to scrape Reddit with Python and BeautifulSoup. Here we will use Beautiful Soup and the request module to scrape the data. Module neededbs4: Beautiful Soup(bs4) is a Python library for pulling data out of HTML and XML files. This module does not come built-in 3 min read How to get YouTube video data by using YouTube data API and PHP ? Thumbnails are used for a preview of a single or group of media entities in a single explorer window. It saves time and gives a better focus to the user's attention and help us grab attention and educate viewer enhancing web design project. The description is a few words more than the title. The mor 5 min read Like