📜  Python IMDbPY – 从搜索到的公司中获取名称

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

Python IMDbPY – 从搜索到的公司中获取名称

在本文中,我们将了解如何从搜索的公司列表中获取电影公司的名称,我们使用search_company方法查找所有相关公司。

search_company方法返回列表,列表的每个元素都作为字典工作,即可以通过给出数据的键来查询它们,这里的键是名称。

下面是实现:

# importing the module
import imdb
   
# creating instance of IMDb
ia = imdb.IMDb()
   
# name of the company
name = "Universal Studios Hollywood"
   
# searching the name of the company
search = ia.search_company(name)
  
# printing the search
print(search)
  
# printing the name
for i in range(len(search)):
    print(search[i]['name'])

输出 :

[Company id:0017927[http] name:_Universal Studios Hollywood [us]_]
Universal Studios Hollywood

另一个例子

# importing the module
import imdb
   
# creating instance of IMDb
ia = imdb.IMDb()
   
# name of the company
name = "Walt Disney"
   
# searching the name of the company
search = ia.search_company(name)
  
  
# printing the name
for i in range(len(search)):
    print(search[i]['name'])

输出 :

Walt Disney Studios Motion Pictures
Walt Disney Pictures
Walt Disney Studios Motion Pictures
Walt Disney Studios
Walt Disney Animation Studios
The Walt Disney Company
Walt Disney Company
Walt Disney Company
Walt Disney Television
Walt Disney Home Video
Walt Disney Home Video
Walt Disney Productions
Walt Disney Company Nordic
Walt Disney Company
Walt Disney Attractions
The Walt Disney Company
Walt Disney Animation U.K.
Walt Disney Motion Pictures Group
Walt Disney Company
Walt Disney International