Web Scraping YouTube Comments

YouTube’s comments section is often more interesting than the video itself. Comments contain a wealth of information related to the video in the form of user submitted feedback and reviews. This article explains how comments can be scraped from YouTube videos.

Details like profile name, comment text, number of likes and replies etc. can be scraped from each comment displayed below a YouTube video.

Steps to follow

The video displayed below shows the steps which you need to follow to scrape comments from YouTube videos. You will need to download and install WebHarvy in your computer. WebHarvy is an easy to use visual web scraping software which can be used to scrape data from any website.

  • First you will need to download and install WebHarvy in your computer.
  • Then load the YouTube video page within WebHarvy
  • Scroll down so that the comments are loaded and displayed
  • Start Configuration
  • Click and select required data. When you click over a data item (like comment text), WebHarvy will display a Capture window with various options. Click the Capture Text option to scrape the text of the item.
  • Once you have selected all required data, go to the Configuration menu tab and select Set JavaScript under Pagination pane.
  • In the resulting window, paste the following code, select the ‘Load More Data’ option and Apply.
document.getElementById('comments').scrollIntoView();
els = document.getElementsByTagName('ytd-comment-thread-renderer');
els[els.length-1].scrollIntoView();

Have Questions? Need Help?

If you are new to WebHarvy we recommend that you refer the getting started guide.

If you have any questions you may contact us.

Related Articles:

  1. Scraping YouTube Video Details