Python IMDbPY – Getting image(head-shot) of person
In this article we will see how we can get the image/head-shot of the person from the person object, imdb person object act similar to dictionary therefore getting image from person object is similar from getting required information from the dictionary.
In order to do this we have to do the following –
1. Get the person object with the help of id by using get_person method
2. Get the image link from it using result[‘headshot’] as keys
3. Print the result
Note : Output will be the link of the image i.e string data type not actual image
Below is the implementation
Python3
import imdb
ia = imdb.IMDb()
code = "1372788"
actor = ia.get_person(code)
print (actor)
image = actor[ 'headshot' ]
print (image)
|
Output :
Shahid Kapoor
https://m.media-amazon.com/images/M/MV5BMjc5NTM5NjUyMV5BMl5BanBnXkFtZTgwMDEwMzU1OTE@._V1_UX67_CR0, 0, 67, 98_AL_.jpg
When we open the output link this will get displayed
Another example
Python3
import imdb
ia = imdb.IMDb()
code = "1596350"
actor = ia.get_person(code)
print (actor)
image = actor[ 'headshot' ]
print (image)
|
Output :
Nawazuddin Siddiqui
https://m.media-amazon.com/images/M/MV5BMTU5NTQwMTI0NV5BMl5BanBnXkFtZTcwNzQyNTgxOA@@._V1_UX67_CR0, 0, 67, 98_AL_.jpg
When we open the link this will be shown
Last Updated :
21 Aug, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...