Python IMDbPY - 将信息集添加到搜索的电影
在本文中,我们将看到如何将信息集添加到搜索的电影中,搜索电影检索固定的数据集并且没有信息集的概念。因此,电影对象的信息将比默认信息集更少。例如,如果您使用搜索方法,则结果中的电影对象不会有许多电影获取方法中可用的键。
为了将信息集添加到搜索到的电影中,我们将使用update
方法。
Syntax : imdb_object.update(movie_object, info = [‘plot’, ‘taglines’])
Argument : It take two argument one is the movie object for which we want more information and the other is the info set i.e list of keys
Action performed : It will retrieve the info set information
下面是实现——
# importing the module
import imdb
# creating instance of IMDb
ia = imdb.IMDb()
# name
name = "3 idiots"
# searching the name
movies = ia.search_movie(name)
movie = movies[0]
# getting more information
ia.update(movie, info = ['taglines'])
# printing tagline
print(movie['taglines'])
输出 :
["Don't be Stupid. Be an I.D.I.O.T."]
另一个例子
# importing the module
import imdb
# creating instance of IMDb
ia = imdb.IMDb()
# name
name = "Success story"
# searching the name
movies = ia.search_movie(name)
movie = movies[0]
# getting more information
ia.update(movie, info = ['plot'])
# printing plot
print(movie['plot'])
输出 :
[“Panagis Pandoras: a wealthy psychiatrist, from a publishing background, charming and unscrupulous. Tzortzina Tzelepi: an unemployed actress, daughter of a bourgeois couple, beautiful and determined to succeed. The two of them, despite being polar opposites, suddenly fall in love, recklessly and passionately, and get married. Tzortzina, in a desperate effort to fit in Panagis’s world, denies her true self. Her creative dead-end, combined with a difficult pregnancy, completely transform her as she is starting to realize that nothing in her married life is as she imagined. The radical change in financial terms, Panagis’s father suicide over debt, and Panagis’s upcoming involvement in politics, sharpen their differences. The admiration, passion and attraction, have now given their place to disappointment, isolation and antagonism. Then, the ruthlessness starts, and their love story ultimately becomes a tale of revenge and hate, as they both resort to extremes, in order to survive.”]