Python 3 Web Scraping Script to Get Movie Info Using IMDb Website and Save to JSON File
562 views
Jun 3, 2025
Get the full source code of application here: https://codingshiksha.com/python/python-3-web-scraping-script-to-get-movie-info-using-imdb-website-and-save-to-json-file/
View Video Transcript
0:00
uh hello guys uh welcome to this video
0:02
so in this video I will show you a
0:04
Python module uh which will actually
0:06
return you the movie information any
0:09
sort of movie in the world you can input
0:12
that movie name and then it will return
0:13
you the information inside a JSON file
0:16
such as the title of the movie the plot
0:19
director rating cast the year of release
0:22
everything it will return it inside a
0:24
JSON file so this is actually the Python
0:27
script here I input the movie name right
0:30
here you can see Jurassic Park and let
0:33
me run this script here so as soon as I
0:36
run this you will see it will create
0:39
this JSON file on the left hand side it
0:42
will take some 5 to 8 seconds and then
0:44
it will create this uh JSON file so
0:47
movie info has been saved so you will
0:51
see it has created this JSON file if I
0:54
try to open this you will see it
0:56
contains the title of the video sorry
0:58
movie then the year of release and then
1:02
it's a gen what is the type of the movie
1:06
action adventure like this who is the
1:10
director you will see the
1:12
rating what is the plot here you get the
1:16
description of the movie and then the
1:18
cast here which who are the actors who
1:20
performed in this uh movie everything
1:23
you get guys you will see and for this
1:26
we are using the internet movie database
1:28
API I which is commonly known known as
1:32
IMDb API and as you can see we we are
1:36
not passing any API key because this
1:38
module is actually scraping this
1:41
internet movie database website and
1:44
getting the required information for
1:47
this you don't need the API key so I
1:50
will show you this Python module let me
1:52
try this with a different
1:55
movie so I call this as
1:59
any other movie you
2:05
can so I just put this movie name again
2:11
i run this so once again it will search
2:15
or scrape the website with this movie
2:19
name and it will return the data you
2:21
will
2:23
see the title here the year of
2:28
release so it works with all the
2:30
languages all the countries or movies as
2:33
you can see everything has been
2:37
scraped so in this easy way let me show
2:40
you the website it's very popular
2:42
website
2:44
IMDb if you search on Google this is the
2:47
most popular website regarding movies
2:51
so they do offer their API but uh that
2:54
requires some subscription fees as well
2:58
so I am just telling you the free way so
3:02
there is a Python module that you can
3:05
use the module name is IMDb so just
3:09
search IM
3:16
so this is the module if you search it i
3:20
think
3:25
this yeah so this is actually the module
3:28
here so you simply install
3:34
this so now let me show you the actual
3:37
script here
3:43
so now just create a simple app py file
3:47
let me delete
3:51
this so first of all what we need to do
3:54
uh we just need to import this package
3:57
IMDb from this we need to import this
4:00
and then we also need the JSON module as
4:02
well and then we construct a new
4:05
instance of this
4:08
and then we search for the movie we give
4:11
the title of the movie which movie you
4:13
are talking
4:17
about and then it will search this I a
4:22
and it contains this function which is
4:24
search
4:25
movie so you can see it has all those
4:28
methods can even search a character
4:31
company episode as well but there is a
4:34
function for searching the movie and you
4:37
need to pass the movie title after that
4:40
if the movie exist then we will get the
4:43
information which is get underscore
4:47
movie so you can see all these functions
4:50
are there get box office movies all
4:52
these functions are
4:54
there so it's a great module so now we
4:57
can get the movie the first
4:59
movie and then the movie ID first of all
5:02
we need to find out the movie ID after
5:05
that using this we can extract all this
5:08
information inside an JSON object so
5:12
here we can extract all this information
5:15
first of all the title then the year of
5:19
release and then the rating and the then
5:23
the director
5:28
so you can see if a movie has multiple
5:31
directors then it will loop through and
5:33
then return next thing we can get is
5:37
your the
5:40
plot like
5:43
this so this is I
5:52
think
5:54
plot
5:57
outline and then we also have the
6:03
cast to get the cast here we simply say
6:15
actor
6:18
so we get the top 10 members of the
6:22
movie in this
6:27
way so the full script I have given in
6:29
the description of this video so if you
6:31
need the full script you can go to the
6:33
description link after getting this we
6:36
simply save this data
6:38
inside a JSON file
6:41
so after we get this data we simply save
6:45
this
6:48
information simply use the open function
6:51
and create
6:53
this movie.json JSON
6:57
file and dump this data after that we
7:01
can write a simple print
7:06
line your data has been
7:09
saved so this is the actual script if I
7:14
execute once again you will see it will
7:17
scrape all this information of the movie
7:20
and save it to a JSON file
7:23
and you can see
7:29
that you can
7:37
see everything has been
7:43
scraped so this is actually the thing
7:46
guys you can directly use it this is a
7:49
free module which communicates with the
7:52
internet movie database
7:56
API uh I think I forgotten the name here
8:00
of the module let just wait
8:03
i got this from chat GPT just wait let
8:07
me show you the
8:10
module i was chatting with this just
8:13
wait let me search for the actual
8:17
library
8:34
uh I think I was there inside
8:39
here where
8:45
IMDb yeah so simply type here IMDb this
8:49
is the page you will get
8:55
so let me
8:57
just submit this to chat GPT and they
9:00
will tell me exactly tell me the module
9:04
name for this i forgot this let me tell
9:09
you the exact Yeah so this is actually
9:12
the module here pip install yeah so
9:16
exactly search for this module
9:21
imdb py so this is actually the module
9:24
here so yeah so this is the actual
9:27
module simply install this by executing
9:30
this command pip install imdb
9:33
py so this is the exact module so it is
9:37
not a very popular module but still it
9:39
works so I basically tried this and it
9:43
works every time whenever you put any
9:46
movie name it will return all this
9:48
information so thank you very much for
9:51
watching this video and also check out
9:53
my website freemediatools.com
9:56
uh which contains thousands of tools
#Animated Films
#Documentary Films
#DVD & Video Shopping
#Movie Listings & Theater Showtimes
#Movie Reference
#Movies
#Scripting Languages