How to Scrape List of YouTube Videos from Any Channel With Python 🐍
If you're looking to pull all the YouTube Videos off a channel (with video title) and output them into a csv file or a comma separated .txt file, this blog is for you. I also decided to scrape YouTube Channels using channel names vs. the commonly used channel IDs, since some channels have already add a unique string to their URLs. Example:
I've looked at different resources, and I highly recommend you learn to read and use the YouTube API documentation. I also recommend you learn how to use Google Cloud APIs and how to create an API key for YouTube. The process is pretty straight forward:
How to create a YouTube API key
- Log in to Google Developers Console
- Create a new project.
- On the new project dashboard, click Explore & Enable APIs.
- In the library, navigate to YouTube Data API v3 under YouTube APIs.
- Enable the API.
- Create a credential.
- A screen will appear with the API key.
For more details checkout this resource.
Once you have your API key, the rest is piece of cake!
Here's the code, all you need to do from here is just add your API key and your channel name. You can also easily modify the code to get the channel name as input from the user. Here's the code:
That's that! You'll end up with a file that has a list of Video URLs and their titles. Happy coding!
Photo Credit: Midjourney. Prompt: computer screen showing code --v 5 --ar 3:2
The SEO Riddler Newsletter
Join the newsletter to receive the latest updates in your inbox.