IMDbPY is a Python package which is used to retrieve and manage the data of the IMDb.
Python IMDbPY – Searching a movie
IMDb is an online database of information related to films, television programs, home videos, video games, and streaming content online – including cast, production crew and personal biographies, plot summaries, trivia, fan and critical reviews, and ratings.
In this article we will see how we can install this module and use this module to fetch variety of information.
Installation
In order to extract data from IMDb, we must first install the Python IMDbPY library. This can be done by entering the command below in your command prompt or terminal,
pip install IMDbPY
Searching a movie
We can search a movie with the help of search_movie
Syntax : imdb_object.search_movie(name)
Argument : It takes string as argument, which is the movie name.
Return : It return list, items in list have same or similar title to the searched movie.
Explanation:
Here we are importing the imdb module of python for searching the movie details through the instance of imdb and hence searching the movie details using the search_movie() method.
Example 1:
Python3
# importing the module import imdb # creating an instance of the IMDB() ia = imdb.IMDb() # Using the Search movie method items = ia.search_movie( 'Avengers' ) for i in items: print (i) |
Output:
The Avengers Marvel's Avengers Avengers: United They Stand Avengers: Endgame Avengers: Infinity War Avengers: Age of Ultron Avengers: The Kang Dynasty Avengers: Secret Wars The Avengers The Avengers Passengers Avengement Captain America: The First Avenger Avengers Assemble Avenger Avenged Tokyo Revengers The Toxic Avenger The Toxic Avenger Challengers
Example 2:
Python3
# importing the module import imdb # creating instance of IMDb ia = imdb.IMDb() # movie name name = " 3 idiots" # searching the movie search = ia.search_movie(name) # printing the result for i in search: print (i) |
Output :
3 Idiots 3 idiotas 3 Idiots 3 Idiots w/ GUNS 3 Idiots on Wheels 3 Idiots Try Candy! 3 Idiots; How Cho Copes with Slump The Idiots Idiots Vidiots Idiotest The Idiot Idiotsitter Idiots Idioten 4 Idiots Idiots Idiots Los 3 Idiotas iDiots
Example 3:
Python3
# importing the module import imdb # creating instance of IMDb ia = imdb.IMDb() # movie name name = "Tarzan the wonder car" # searching the movie search = ia.search_movie(name) # printing the result print (search) |
Output :
[Movie id:0435437[http] title:_Taarzan: The Wonder Car (2004)_>]