Python IMDbPY - 获取人物的 IMDb 索引
在本文中,我们将看到如何从 imdb 数据库中获取人员的索引,imdb 已经给出人员索引来对他们进行分类索引不是数值它是罗马数字,例如 Salman Khan,SRK 也有 (I) 作为索引有些人没有被索引。下面是显示人物索引的图像
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_filmography method
2. Get the index from it using result[‘data’][‘imdbIndex’] as keys
3. Print the result
注意:输出将是图像的链接,即字符串数据类型不是实际图像
下面是实现
Python3
# importing the module
import imdb
# creating instance of IMDb
ia = imdb.IMDb()
# person id
code = "1372788"
# getting person object
actor = ia.get_person_filmography(code)
# printing object name
print(actor['data']['name'])
# getting index
index = actor['data']['imdbIndex']
# printing
print(index)
Python3
# importing the module
import imdb
# creating instance of IMDb
ia = imdb.IMDb()
# person id
code = "0262635"
# getting person object
actor = ia.get_person_filmography(code)
# printing object name
print(actor['data']['name'])
# getting index
index = actor['data']['imdbIndex']
# printing
print(index)
输出 :
Shahid Kapoor
I
另一个例子
Python3
# importing the module
import imdb
# creating instance of IMDb
ia = imdb.IMDb()
# person id
code = "0262635"
# getting person object
actor = ia.get_person_filmography(code)
# printing object name
print(actor['data']['name'])
# getting index
index = actor['data']['imdbIndex']
# printing
print(index)
输出 :
Chris Evans
V