Python IMDbPY – Getting title from searched movie
Last Updated :
20 Aug, 2021
In this article we will see how we can get the title of movie from the searched list of movies. We use search_movie method to find all the related movies. search_movie method returns list and each element of list work as a dictionary i.e. they can be queried by giving the key of the data, here key will be title.
Syntax : movies[0][‘title’]
Here movies is the list return by search_movie method and movies[0] refer to the first element of list.
Return : It returns string i.e title.
Below is the implementation:
Python3
import imdb
ia = imdb.IMDb()
name = "Jab Taare Utare Zameen Par"
search = ia.search_movie(name)
print (search)
for i in range ( len (search)):
print (search[i][ 'title' ])
|
Output :
[Movie id:8142208[http] title:_Jab Taare Utare Zameen Par (2017)_]
Jab Taare Utare Zameen Par
Another example
Python3
import imdb
ia = imdb.IMDb()
name = "Udta punjab"
search = ia.search_movie(name)
for i in range ( len (search)):
print (search[i][ 'title' ])
|
Output :
Udta Punjab
Diljit Dosanjh (Udta Punjab)
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...