📜  Python IMDbPY - 获取人的图像(头像)

📅  最后修改于: 2022-05-13 01:55:41.493000             🧑  作者: Mango

Python IMDbPY - 获取人的图像(头像)

在本文中,我们将看到如何从人员对象中获取人员的图像/头像,imdb 人员对象的行为类似于字典,因此从人员对象获取图像类似于从字典中获取所需信息。

注意:输出将是图像的链接,即字符串数据类型不是实际图像

下面是实现

Python3
# importing the module
import imdb
 
# creating instance of IMDb
ia = imdb.IMDb()
 
# person id
code = "1372788"
 
# getting person object
actor = ia.get_person(code)
 
# printing object it prints its name
print(actor)
 
# getting image
image = actor['headshot']
 
# printing the place
print(image)


Python3
# importing the module
import imdb
 
# creating instance of IMDb
ia = imdb.IMDb()
 
# person id
code = "1596350"
 
# getting person object
actor = ia.get_person(code)
 
# printing object it prints its name
print(actor)
 
# getting image
image = actor['headshot']
 
# printing the place
print(image)


输出 :

Shahid Kapoor
https://m.media-amazon.com/images/M/MV5BMjc5NTM5NjUyMV5BMl5BanBnXkFtZTgwMDEwMzU1OTE@._V1_UX67_CR0, 0, 67, 98_AL_.jpg

当我们打开输出链接时,这将显示

另一个例子

Python3

# importing the module
import imdb
 
# creating instance of IMDb
ia = imdb.IMDb()
 
# person id
code = "1596350"
 
# getting person object
actor = ia.get_person(code)
 
# printing object it prints its name
print(actor)
 
# getting image
image = actor['headshot']
 
# printing the place
print(image)

输出 :

Nawazuddin Siddiqui
https://m.media-amazon.com/images/M/MV5BMTU5NTQwMTI0NV5BMl5BanBnXkFtZTcwNzQyNTgxOA@@._V1_UX67_CR0, 0, 67, 98_AL_.jpg

当我们打开链接时,这将显示