📌  相关文章
📜  Python IMDbPY - 从电影对象中检索艺术部门演员表

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

Python IMDbPY - 从电影对象中检索艺术部门演员表

在本文中,我们将了解如何从电影信息中检索电影中涉及的艺术部门演员表,电影 id 是 IMDb 赋予每部电影的唯一 id。我们可以使用 search_movie 方法按名称搜索电影,但它会给出许多电影,因为它们具有相同的名称,因此通过其 id 检索电影是更好的选择。

为了通过 id 搜索电影,我们使用get_movie方法。

下面是实现。

# importing the module
import imdb
  
# creating instance of IMDb
ia = imdb.IMDb()
  
# ID
code = "1187043"
  
# getting movie
movie = ia.get_movie(code)
  
# printing movie object
print(movie)
  
print("===============")
  
# getting cast
cast = movie['art department']
  
# actor name from caste
actor = cast[1]
  
print(actor)

输出 :

3 Idiots
===============
Ajay Chodanker

另一个例子 :

# importing the module
import imdb
  
# creating instance of IMDb
ia = imdb.IMDb()
  
# ID
code = "4434004"
  
# getting movie
movie = ia.get_movie(code)
  
# printing movie object
print(movie)
  
print("===============")
  
# getting cast
cast = movie['art department']
  
# printing actors name from caste
print(cast[0])

输出 :

Udta Punjab
===============
Pallavi Pethkar