Python IMDbPY - 获取演员表演的电影列表
在本文中,我们将了解如何获取演员表演过的电影列表,即演员在各种电影中表演过的电影。 IMDb 拥有一个数据库,其中包含经过验证的演员表演的几乎每部电影。
为了获得演员表演的所有电影的列表,我们必须获得演员的电影细节
Syntax : results = ia.get_person_filmography(ID)
Here ia
is the IMDb object
Argument : It takes Id as argument
Return : It returns dictionary
This method returns the complicated dictionary which is hard to read in order to get the titles of the movie we use results['data']['filmography'][0]['actor'][index]
下面是实现
# importing the module
import imdb
# creating instance of IMDb
ia = imdb.IMDb()
# person id
code = "1372788"
# printing person name
print(ia.get_person(code))
# getting information
actor_results = ia.get_person_filmography(code)
# printing movie name
for index in range(5):
movie_name = actor_results['data']['filmography'][0]['actor'][index]
print(movie_name)
输出 :
Shahid Kapoor
Jersey Hindi Remake
Sachet Tandon: Bekhayali
Kabir Singh
The Insider's Watchlist
Akhil Sachdeva & Tulsi Kumar: Tera Ban Jaunga
另一个例子
# importing the module
import imdb
# creating instance of IMDb
ia = imdb.IMDb()
# person id
code = "0001098"
# printing person name
print(ia.get_person(code))
# getting information
actor_results = ia.get_person_filmography(code)
# printing movie name
for index in range(5):
movie_name = actor_results['data']['filmography'][0]['actor'][index]
print(movie_name)
输出 :
Rodney Dangerfield
Angels with Angles
Still Standing
Back by Midnight
Phil of the Future
The Electric Piper