Python 3 Web Scraping Script to Get All Videos of Youtube Channel Using Youtube Data API V3
21 views
Jun 3, 2025
Buy the full source code of application here:
View Video Transcript
0:00
uh hello guys uh welcome to this video
0:02
so in this video I'll show you a Python
0:04
package uh which allows you to interact
0:07
with the YouTube data API in the
0:09
background and for this you don't need
0:11
any sort of API key it's a web scraping
0:15
uh module uh which the name of the
0:18
module is scrape tube if you go to their
0:22
third
0:23
[Music]
0:24
party package search website just search
0:28
for this scrape tube so you can scrape
0:31
YouTube without the official YouTube API
0:33
and without selenium so this is actually
0:35
the package simply install this package
0:37
here by using the command and I have
0:40
already installed it so this package
0:42
allows you to do this process so first
0:45
of all you import the package so we
0:49
import scrape tube after that we declare
0:52
the variable
0:54
videos we initialize the module scrape
0:57
tube and it contains this method which
1:00
is get
1:02
channel and this basically this method
1:05
expects you to pass the channel ID or
1:09
you can actually also give channel ID
1:12
like this channel URL as well channel
1:15
username as well
1:17
so let's suppose I take an example of
1:20
any YouTube channel let me take my
1:22
YouTube channel as an
1:24
example so what you need to do you just
1:27
need to copy the URL of your channel
1:30
simply copy it and simply pass right
1:34
here channel URL it double quotes paste
1:37
it so now what will happen it will
1:40
actually scrape every video of your
1:42
YouTube channel and return inside this
1:44
videos so now we can loop through all
1:47
these videos which is an
1:52
array and we can print out each video
2:04
so if you run this now you will
2:10
see you can see the JSON response is
2:14
returning each video has some properties
2:17
here video ID title everything we can
2:20
even limit this response coming if you
2:23
don't want the all the videos to be
2:26
appearing you can limit
2:28
is this function which is get underscore
2:30
channel here you can
2:33
specify the limit property as a second
2:36
argument so limit basically allows you
2:39
to limit the results so I only want five
2:42
videos of my channel so now what
2:45
happens you will only get the five
2:48
videos you will see each video has some
2:51
properties attached to it which is
2:53
actually the video ID then we got the
2:56
thumbnails as well and as you can see
2:59
this is a JSON response here we have got
3:02
width and
3:04
height so we also got the title here if
3:08
you see so for printing out the
3:11
individual property here what we can
3:14
do we can say we need to print out the
3:18
title so now it will print out all the
3:21
titles of the video only you will see
3:25
now we have the title here
3:30
Python we can even filter out videos as
3:33
well so there is a third argument that
3:35
you can pass to this function which is
3:37
get channel first is the channel URL
3:40
then you can pass the limit and then
3:42
there is a third option
3:44
which you can
3:47
pass let's suppose you only want to
3:50
get you can apply sort
3:54
by and newest so this means that I want
3:59
the videos to appear which are the
4:01
newest videos you can put this
4:04
restriction so if you put this
4:06
restriction you will see you will only
4:08
get the newest videos new five videos of
4:11
my channel
4:15
so if you only want the video ID you can
4:18
change this to video ID so now this will
4:20
print out the video ID the top latest
4:24
five videos from my channel 1 2 3 4 5
4:28
you can change this let's suppose I want
4:30
the 10 videos so now it will search your
4:33
YouTube channel and it will return out
4:35
the 10 videos this is their video ID so
4:39
this is you can see you guys we I
4:41
haven't used any YouTube data API we
4:45
haven't used the API key but it is using
4:48
the YouTube data API which is the
4:51
official API in the background to
4:54
actually collect all the data from
4:55
YouTube by means of web scraping which
4:58
is a technique by which you can get data
5:00
from a website so this is actually a
5:03
very famous module guys definitely
5:05
install it it works i personally tested
5:08
it out it's a great module install it
5:12
and also check out my website free media
5:15
tools.com uh which contains thousands of
5:18
tools and I will be seeing you in the
#Online Video
#Programming
#Scripting Languages
#Video Sharing