Python IMDbPY – Getting person ID from searched persons
In this article we will see how we can get the person id from searched person, person id is basically unique id given to each person names can be same of some people but id will be distinct. We use search_person
method to get people with the same name.
In order to get person id we use personID
method.
Syntax : persons[0].personID
Here persons is the list of person returned by search_person and persons[0] refer to first element in list
Argument : It takes no argument.
Return : It return string which is Person ID
Below is the implementation.
import imdb
ia = imdb.IMDb()
name = "Ayushmann Khurrana"
search = ia.search_person(name)
for i in range ( len (search)):
id = search[i].personID
print (search[i][ 'name' ] + " : " + id )
|
Output :
Ayushmann Khurrana : 4731677
Another example
import imdb
ia = imdb.IMDb()
name = "Pankaj Tripathi"
search = ia.search_person(name)
for i in range ( len (search)):
id = search[i].personID
print (search[i][ 'name' ] + " : " + id )
|
Output :
Pankaj Tripathi : 2690647
Pankaj Tripathi : 11337375
Sankalp Raj Tripathi : 9704712
Last Updated :
22 Apr, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...