Python IMDbPY – 获取前 250 部电影
在本文中,我们将看到如何检索 IMDb 数据库中前 250 部电影的信息,IMDb 为所有电影设置评分。
为了获得 IMDb 的前 250 部电影,我们将使用get_top250_movies
方法。
Syntax : imdb_object.get_top250_movies()
Argument : It takes no argument
Return : It returns list of 250 element and each element is idbm movie object
下面是实现
# importing the module
import imdb
# creating instance of IMDb
ia = imdb.IMDb()
# getting top 250 movies
search = ia.get_top250_movies()
# printing only first 10 movies title
for i in range(10):
print(search[i]['title'])
输出 :
The Shawshank Redemption
The Godfather
The Godfather: Part II
The Dark Knight
12 Angry Men
Schindler's List
The Lord of the Rings: The Return of the King
Pulp Fiction
The Good, the Bad and the Ugly
The Lord of the Rings: The Fellowship of the Ring