How to scrape YouTube data: step-by-step guide in 2024

YouTube is the biggest video hosting on the internet. Discover how to use web scraping to extract useful data from YouTube videos, captions, and comments.

Content

YouTube is a treasure pile of data just waiting to be discovered. And the best news here is: now all that YouTube data is scrapable. Yeah, you’ve read it right – it is now possible to scrape video content as well and we’ll show you how it’s done.

Here’s a short step-by-step tutorial on how our web scraping tools, YouTube Scraper can carry out web scraping on YouTube. It will extract data from channels, streams, Shorts, playlists, and searches easily by cherry-picking data from selected YouTube video pages. It will enable you to scrape channels, all their videos, and their details, as well as fine-tune your search. Last but not least, you will learn how to scrape both auto-generated and added captions in various languages.

Quick YouTube tutorial on scraping YouTube.

How to scrape YouTube

  1. Go to the YouTube Scraper page on Apify Store.
  2. Choose a keyword to scrape YouTube search results.
  3. Choose URLs to scrape YouTube channels or scrape YouTube videos.
  4. Choose whether to scrape YouTube subtitles.
  5. Collect your YouTube data.
  6. Preview and export your listings.

Step 1. Go to the YouTube Scraper page on Apify Store

What YouTube Scraper page on Apify Store looks like
YouTube Scraper page on Apify Store

Go to YouTube Scraper and click the Try for free button. You’ll then need to sign up for a free plan or sign in to Apify Console, which can also be done via your GitHub or Google account to speed up the process.

Step 2. Choose a keyword to scrape YouTube search results

To scrape YouTube data by a Search term 🔍, just add a keyword to the first field.
To scrape YouTube data by a Search term 🔍, just add a keyword to the first field.

After you’re signed in, it's time to set up your YouTube Scraper. Here, you first decide whether you want to scrape YouTube data by a Search term 🔍 or a specific URL 🔗. Let's try the Search term first and see if we can scrape all the videos from YouTube's search page that match it. You can only add one Search term per run.

Choose the number of videos to scrape

If you're scraping YouTube videos by Search term, it's useful to limit the number of videos you expect to scrape. In the next section, pick the number of videos and/or Shorts, streams you expect in your YouTube dataset.

Set up how many YouTube videos you want to target if you're scraping YouTube by Search term
Set up how many YouTube videos you want to target if you're scraping YouTube by Search term

Set up filters and video sorting parameters

Additionally, to narrow down your scraped results even more, you can use Filtering & Sorting for Search and Channel sorting/filtering. There you can choose video groups by popularity, newness, video type, video length, quality, and more.

What the Sorting and filtering part of the input looks like
Sorting and filtering part of the input is not mandatory

Step 3. Choose URLs to scrape YouTube channels or scrape YouTube videos

To scrape YouTube data by a URL 🔗, just add URLs you want to scrape from YouTube. You can add channel URL, video URL, playlist URL, or search URL.
To scrape YouTube videos by a URL 🔗, just add URLs you want to scrape from YouTube. You can add channel URL, video URL, playlist URL, or search URL.

Alternatively to Search term scraping, you can scrape YouTube by URLs 🔗. Just head over to the YouTube site and copy any URL you want to scrape content from: channel URL, video URL, playlist URL, or search URL. Then paste it into the Direct URLs part. An advantage of the Direct URLs section is that you can add many URLs at once.

Step 4. Choose whether to scrape YouTube subtitles

Additionally, you can set up subtitles extraction in Scraping subtitles section. You can pick the subtitles format, language, as well as storage. This is also a place where you set up scraping auto-generated subtitles or those added by humans.

Step 5. Collect your YouTube data

No matter which way you've chosen to scrape YouTube videos – by Search term or by URLs, the next step is to click Start and wait for your data to load. The time long it will take to extract the data depends on your predefined number of results, whether you selected video details when scraping a YouTube channel.

Scraper results page on Apify Console
Your results should start popping up in the Output tab

Step 6. Preview and export your listings

To see the complete results after the extraction is over, head on to the Storage tab. Here, you can download YouTube data in different formats, such as Excel, JSON, CSV, XML, HTML, or RSS. You can also prefilter the fields you want to extract or omit. Just proceed to the Export button and choose your parameters in the popup window.

Storage tab on scraper's output page showing the various available formats
Each file format has multiple options on how to get access to your data

Now that you know how to scrape YouTube, you can take it a step further and dig deeper into its input options, connect it to other web apps with Apify Integrations or maybe even try building your own scraper and monetizing your code.

👨‍💻
See how devs from our community publish their own web scrapers and find their users.

YouTube API vs. YouTube scraping

YouTube does have its own API enabling you to do some basic content search and collect data from each video. However, the YouTube API has significant limitations: YouTube scraping is limited to video data, subscriptions, recommendations, ranking, and ads. In addition, YouTube API has a strong anti-scraping system in place, and it requires you to log in and imposes quota limits.

It seems like what you need is some kind of scraper that is flexible enough for various parameters, simple enough to use, but also strong enough to withstand the anti-bot blocking. Sure, you can try your hand at coding your own scraper. But why reinvent the wheel when you can try our ready-made tools, like our YouTube Scraper.

Does YouTube allow web scraping?

Most data found on YouTube is accessible to the general public, making it legal to scrape. But it’s still important to comply with regulations that deal with personal data and copyright protection. To learn more about the legal context of web scraping, check out our blog article on the subject.

More YouTube scraping tools

📹
Interested in scrapers for other video platforms? Check out our video category on Apify Store.

How do I scrape YouTube Shorts?

To scrape YouTube Shorts, you can use either the YouTube Scraper (by both Search term 🔍 and Direct URLs 🔗 sections) or the YouTube Shorts Scraper. Both are good fits for this scraping case; YouTube Shorts Scraper is simply more focused scraping tool.

How do I scrape YouTube emails?

To scrape emails from YouTube channels by search word, use the YouTube Email Scraper. However, please note that scraping emails is close to scraping personal data and requires you to log into YouTube.

How to scrape YouTube channels?

To scrape YouTube channel details, you can use either the YouTube Scraper (in the Direct URLs section) or the YouTube Channel Scraper. Both are good fits for this scraping case; YouTube Channel Scraper is simply a more focused scraping tool.

How to scrape YouTube comments?

YouTube Scraper doesn't scrape comment text or commentator details; it only scrapes the total comment count under each video. To scrape comments from YouTube, use the YouTube Comments Scraper. This tool will extract comment text, author name, date posted, vote count, reply count, and more.

💭
Learn how to scrape YouTube comments and export them to Google Drive.

All in all, YouTube offers a vast array of content, from DIYs to live streams. Now, you can scrape this data, and we’ll show you how. How would you use collected YouTube data?

  • Calculate brand mentions and audience reach.
  • Assess ROI for ads or referrals.
  • Improve YouTube SEO.
  • Monitor brand awareness.
  • Analyze the success of your marketing campaigns by assessing activity during live streams.
  • Feed video editors and AI video generators to make creating videos easy.
  • and more!
Natasha Lekh
Natasha Lekh
Crafting content that charms both readers and Google’s algorithms: readmes, blogs, and SEO secrets.

Get started now

Step up your web scraping and automation